home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / man / man3 < prev    next >
Text File  |  1990-07-19  |  97KB  |  2,502 lines

  1. #INTRO
  2. NAME
  3.       intro    - introduction to subroutines and libraries
  4. SYNTAX
  5.       #include <stdio.h>
  6.       #include <math.h>
  7. DESCRIPTION
  8.       This section describes functions found in various libraries,
  9.       other    than those functions that directly invoke UNIX system
  10.       primitives, which are    described in Section 2 of this volume.
  11.       Certain major    collections are    identified by a    letter after
  12.       the section number:
  13.       (3C)    These functions, together with those of    Section    2 and
  14.         those marked (3S), constitute the Standard C Library
  15.         libc, which is automatically loaded by the C compiler,
  16.         cc(1).    The link editor    ld(1) searches this library
  17.         under the -lc option.  Declarations for    some of    these
  18.         functions may be obtained from #include    files
  19.         indicated on the appropriate pages.
  20.       (3S)    These functions    constitute the ``standard I/O
  21.         package'' [see stdio(3S)].  These functions are    in the
  22.         library    libc, already mentioned.  Declarations for
  23.         these functions    may be obtained    from the #include file
  24.         <stdio.h>.
  25.       (3M)    These functions    constitute the Math Library, libm.
  26.         They are automatically loaded as needed    by the FORTRAN
  27.         compiler f77(1).  They are not automatically loaded by
  28.         the C compiler,    cc(1); however,    the link editor
  29.         searches this library under the    -lm option.
  30.         Declarations for these functions may be    obtained from
  31.         the #include file <math.h>.  Several generally useful
  32.         mathematical constants are also    defined    there [see
  33.         math(5)].
  34.       (3X)    Various    specialized libraries.    The files in which
  35.         these libraries    are found are given on the appropriate
  36.         pages.
  37.       (3F)    These functions    constitute the FORTRAN intrinsic
  38.         function library, libF77.  These functions are
  39.         automatically available    to the FORTRAN programmer and
  40.         require    no special invocation of the compiler.
  41.       There    are separate library files for use with    small, large
  42.       and huge model programs (see "Files,"    below).     Normally,
  43.       ld(1)    automatically selects the correct library file for the
  44.       memory model you are using.  However,    if you specify the
  45.       library file yourself, be sure that it matches the memory
  46.       model    of your    program.
  47.      DEFINITIONS
  48.                   
  49.       A character is any bit pattern able to fit into a byte on
  50.       the machine.    The null character is a    character with value
  51.       0, represented in the    C language as '\0'.  A character array
  52.       is a sequence    of characters.    A null-terminated character
  53.       array    is a sequence of characters, the last of which is the
  54.       null character.  A string is a designation for a null-
  55.       terminated character array.  The null    string is a character
  56.       array    containing only    the null character.  A NULL pointer is
  57.       the value that is obtained by    casting    0 into a pointer.  The
  58.       C language guarantees    that this value    will not match that of
  59.       any legitimate pointer, so many functions that return
  60.       pointers return it to    indicate an error.  NULL is defined as
  61.       0 in <stdio.h>; the user can include an appropriate
  62.       definition if    not using <stdio.h>.
  63.       Many groups of FORTRAN intrinsic functions have generic
  64.       function names that do not require explicit or implicit type
  65.       declaration.    The type of the    function will be determined by
  66.       the type of its argument(s).    For example, the generic
  67.       function max will return an integer value if given integer
  68.       arguments (max0), a real value if given real arguments
  69.       (amax1), or a    double-precision value if given    double-
  70.       precision arguments (dmax1).
  71. FILES
  72.       /lib/small/libc.a
  73.       /lib/large/libc.a
  74.       /lib/huge/libc.a
  75.       /lib/small/libm.a
  76.       /lib/large/libm.a
  77.       /lib/huge/libm.a
  78.       /usr/small/lib/libF77.a
  79.       /usr/large/lib/libF77.a
  80.       /usr/huge/lib/libF77.a
  81. SEE ALSO
  82.       intro(2), stdio(3S), math(5).
  83.       ar(1), cc(1),    f77(1),    ld(1), lint(1),    nm(1) in the UNIX
  84.       System V User    Reference Manual.
  85. DIAGNOSTICS
  86.       Functions in the C and Math Libraries    (3C and    3M) may    return
  87.       the conventional values 0 or _HUGE (the largest-magnitude
  88.       single-precision floating-point numbers; HUGE    is defined in
  89.       the <math.h> header file) when the function is undefined for
  90.       the given arguments or when the value    is not representable.
  91.       In these cases, the external variable    errno [see intro(2)]
  92.       is set to the    value EDOM or ERANGE.  As many of the FORTRAN
  93.       intrinsic functions use the routines found in    the Math
  94.       Library, the same conventions    apply.
  95.      WARNING
  96.       Many of the functions    in the libraries call and/or refer to
  97.       other    functions and external variables described in this
  98.       section and in section 2 (System Calls).  If a program
  99.       inadvertantly    defines    a function or external variable    with
  100.       the same name, the presumed library version of the function
  101.       or external variable may not be loaded.  The lint(1) program
  102.       checker reports name conflicts of this kind as ``multiple
  103.       declarations'' of the    names in question.  Definitions    for
  104.       sections 2, 3C, and 3S are checked automatically.  Other
  105.       definitions can be included by using the -l option (for
  106.       example, -lm includes    definitions for    the Math Library,
  107.       section 3M).    Use of lint is highly recommended.
  108.  
  109. #abs
  110. NAME
  111.       abs -    return integer absolute    value
  112. SYNTAX
  113.       int abs (i)
  114.       int i;
  115. DESCRIPTION
  116.       Abs returns the absolute value of its    integer    operand.
  117. BUGS
  118.       In two's-complement representation, the absolute value of
  119.       the negative integer with largest magnitude is undefined.
  120.       Some implementations trap this error,    but others simply
  121.       ignore it.
  122. SEE ALSO
  123.       floor(3M).
  124.                   
  125. NAME
  126.       abs, iabs, dabs, cabs, zabs -    FORTRAN    absolute value
  127. SYNTAX
  128.       integer i1, i2
  129.       real r1, r2
  130.       double precision dp1,    dp2
  131.       complex cx1, cx2
  132.       double complex dx1, dx2
  133.       r2 = abs(r1)
  134.       i2 = iabs(i1)
  135.       i2 = abs(i1)
  136.       dp2 =    dabs(dp1)
  137.       dp2 =    abs(dp1)
  138.       cx2 =    cabs(cx1)
  139.       cx2 =    abs(cx1)
  140.       dx2 =    zabs(dx1)
  141.       dx2 =    abs(dx1)
  142. DESCRIPTION
  143.       Abs is the family of absolute    value functions.  Iabs returns
  144.       the integer absolute value of    its integer argument.  Dabs
  145.       returns the double-precision absolute    value of its double-
  146.       precision argument.  Cabs returns the    complex    absolute value
  147.       of its complex argument.  Zabs returns the double-complex
  148.       absolute value of its    double-complex argument.  The generic
  149.       form abs returns the type of its argument.
  150. SEE ALSO
  151.       floor(3M).
  152.                   
  153. #crypt
  154. NAME
  155.       crypt, encrypt - a one way hashing encryption    algorithm
  156. SYNTAX
  157.       char *crypt (key, salt)
  158.       char *key, *salt;
  159.       void encrypt (block)
  160.       char *block;
  161. DESCRIPTION
  162.       Crypt    is the password    encryption function.  It is based on a
  163.       one way hashing encryption algorithm with variations
  164.       intended (among other    things)    to frustrate use of hardware
  165.       implementations of a key search.
  166.       Key is a user's typed    password.  Salt    is a two-character
  167.       string chosen    from the set [a-zA-Z0-9./]; this string    is
  168.       used to perturb the hashing algorithm    in one of 4096
  169.       different ways, after    which the password is used as the key
  170.       to encrypt repeatedly    a constant string.  The    returned value
  171.       points to the    encrypted password.  The first two characters
  172.       are the salt itself.
  173.       There    is a character array of    length 64 containing only the
  174.       characters with numerical value 0 and    1.  When this string
  175.       is divided into groups of 8, the low-order bit in each group
  176.       is ignored; this gives a 56-bit key which is set into    the
  177.       machine by crypt.
  178.       The encrypt entry provides (rather primitive)    access to the
  179.       actual hashing algorithm.  The argument to the encrypt entry
  180.       is a character array of length 64 containing only the
  181.       characters with numerical value of 0 and 1.  The argument
  182.       array    is modified in place to    a similar array    representing
  183.       the bits of the argument after having    been subjected to the
  184.       hashing algorithm using the key set by crypt.
  185. SEE ALSO
  186.       getpass(3C), passwd(4).
  187.       login(1), passwd(1) in the UNIX System V User    Reference
  188.       Manual.
  189. BUGS
  190.       The return value points to static data that are overwritten
  191.       by each call.
  192.                   
  193.  
  194. #ctermid
  195. NAME
  196.       ctermid - generate file name for terminal
  197. SYNTAX
  198.       #include <stdio.h>
  199.       char *ctermid    (s)
  200.       char *s;
  201. DESCRIPTION
  202.       Ctermid generates the    path name of the controlling terminal
  203.       for the current process, and stores it in a string.
  204.       If s is a NULL pointer, the string is    stored in an internal
  205.       static area, the contents of which are overwritten at    the
  206.       next call to ctermid,    and the    address    of which is returned.
  207.       Otherwise, s is assumed to point to a    character array    of at
  208.       least    L_ctermid elements; the    path name is placed in this
  209.       array    and the    value of s is returned.     The constant
  210.       L_ctermid is defined in the <stdio.h>    header file.
  211.      NOTES
  212.       The difference between ctermid and ttyname(3C) is that
  213.       ttyname must be handed a file    descriptor and returns the
  214.       actual name of the terminal associated with that file
  215.       descriptor, while ctermid returns a string (/dev/tty)    that
  216.       will refer to    the terminal if    used as    a file name.  Thus
  217.       ttyname is useful only if the    process    already    has at least
  218.       one file open    to a terminal.
  219. SEE ALSO
  220.       ttyname(3C).
  221.                   
  222.  
  223. #ctime
  224. NAME
  225.       ctime, localtime, gmtime, asctime, - convert date and
  226.       time to string
  227. SYNTAX
  228.       #include <time.h>
  229.       char *ctime (clock)
  230.       long *clock;
  231.       struct tm *gmtime (clock)
  232.       long *clock;
  233.       char *asctime    (tm)
  234.       struct tm *tm;
  235. DESCRIPTION
  236.       Ctime    converts a long    integer, pointed to by clock,
  237.       representing the time    in seconds since 00:00:00 GMT, January
  238.       1, 1970, and returns a pointer to a 26-character string in
  239.       the following    form.  All the fields have constant width.
  240.            Sun Sep 16 01:03:52 1973\n\0
  241.       Gmtime returns a pointer to a ``tm'' structure,
  242.       described below. Gmtime converts directly to Greenwich
  243.       Mean Time (GMT), which is the time the UNIX system uses.
  244.       Asctime converts a ``tm'' structure to a 26-character
  245.       string, as shown in the above    example, and returns a pointer
  246.       to the string.
  247.       Declarations of all the functions and    externals, and the
  248.       ``tm'' structure, are    in the <time.h>    header file.  The
  249.       structure declaration    is:
  250.            struct tm {
  251.                int tm_sec; /* seconds (0 - 59) */
  252.                int tm_min; /* minutes (0 - 59) */
  253.                   
  254.                int tm_hour;    /* hours (0 - 23) */
  255.                int tm_mday;    /* day of month    (1 - 31) */
  256.                int tm_mon;    /* month of year (0 - 11) */
  257.                int tm_year;    /* year    - 1900 */
  258.                int tm_wday;    /* day of week (Sunday = 0) */
  259.                int tm_yday;    /* day of year (0 - 365) */
  260.            };
  261. SEE ALSO
  262.       time(2).
  263. BUGS
  264.       The return values point to static data whose content is
  265.       overwritten by each call.
  266.  
  267. #ctype
  268. NAME
  269.       isalpha, isupper, islower, isdigit, isxdigit,    isalnum,
  270.       isspace, ispunct, isprint, isgraph, iscntrl, isascii -
  271.       classify characters
  272. SYNTAX
  273.       #include <ctype.h>
  274.       int isalpha (c)
  275.       int c;
  276.       . . .
  277. DESCRIPTION
  278.       These    macros classify    character-coded    integer    values by
  279.       table    lookup.     Each is a predicate returning nonzero for
  280.       true,    zero for false.     Isascii is defined on all integer
  281.       values; the rest are defined only where isascii is true and
  282.       on the single    non-ASCII value    EOF [-1    - see stdio(3S)].
  283.       isalpha     c is a    letter.
  284.       isupper     c is an upper-case letter.
  285.       islower     c is a    lower-case letter.
  286.       isdigit     c is a    digit [0-9].
  287.       isxdigit     c is a    hexadecimal digit [0-9], [A-F] or [a-
  288.              f].
  289.       isalnum     c is an alphanumeric (letter or digit).
  290.       isspace     c is a    space, tab, carriage return, new-line,
  291.              vertical tab, or form-feed.
  292.       ispunct     c is a    punctuation character (neither control
  293.              nor alphanumeric).
  294.       isprint     c is a    printing character, code 040 (space)
  295.              through 0176 (tilde).
  296.       isgraph     c is a    printing character, like isprint
  297.              except    false for space.
  298.       iscntrl     c is a    delete character (0177)    or an ordinary
  299.              control character (less than 040).
  300.       isascii     c is an ASCII character, code less than 0200.
  301. DIAGNOSTICS
  302.       If the argument to any of these macros is not    in the domain
  303.                   
  304.       of the function, the result is undefined.
  305. SEE ALSO
  306.       stdio(3S), ascii(5).
  307.  
  308. #cuserid
  309. NAME
  310.       cuserid - get    character login    name of    the user
  311. SYNTAX
  312.       #include <stdio.h>
  313.       char *cuserid    (s)
  314.       char *s;
  315. DESCRIPTION
  316.       Cuserid generates a character-string representation of the
  317.       login    name that the owner of the current process is logged
  318.       in under.  If    s is a NULL pointer, this representation is
  319.       generated in an internal static area,    the address of which
  320.       is returned.    Otherwise, s is    assumed    to point to an array
  321.       of at    least L_cuserid    characters; the    representation is left
  322.       in this array.  The constant L_cuserid is defined in the
  323.       <stdio.h> header file.
  324. DIAGNOSTICS
  325.       If the login name cannot be found, cuserid returns a NULL
  326.       pointer; if s    is not a NULL pointer, a null character    (\0)
  327.       will be placed at s[0].
  328. SEE ALSO
  329.       getlogin(3C),    getpwent(3C).
  330.                   
  331.  
  332. #directory
  333. SUBROUTINES
  334.     directory(3)    - directory operations
  335. INVOCATION
  336.     #include <sys/types.h>
  337.     #include <dirent.h>
  338.     DIR *opendir( dirname )
  339.       char *dirname;
  340.     struct dirent *readdir( dirp )
  341.       DIR *dirp;
  342.     off_t telldir( dirp )
  343.       DIR *dirp;
  344.     void seekdir( dirp, loc )
  345.       DIR *dirp;
  346.       off_t loc;
  347.     void rewinddir( dirp )
  348.       DIR *dirp;
  349.     int closedir( dirp )
  350.       DIR *dirp;
  351. EXPLANATION
  352.     Opendir(3) establishes a connection between the directory named
  353.     by <dirname> and a unique object of type DIR known as a
  354.     directory stream that it creates. Opendir(3) returns a pointer
  355.     to be used to identify the directory stream in subsequent
  356.     operations. A NULL pointer is returned if <dirname> cannot be
  357.     accessed or is not a directory, or if opendir(3) is unable to
  358.     create the DIR object (perhaps due to insufficient  memory).
  359.     Readdir(3) returns a pointer to an internal structure containing
  360.     information about the next active directory entry. No inactive
  361.     entries are reported. The internal structure may be overwritten
  362.     by another operation on the same directory stream; the amount of
  363.     storage needed to hold a copy of the internal structure is given
  364.     by the value of a macro, DIRENTSIZ(strlen(direntp->d_name)), not
  365.     by sizeof(struct dirent) as one might expect. A NULL pointer is
  366.     returned upon reaching the end of the directory, upon detecting
  367.     an invalid location in the directory, or upon occurrence of an
  368.     error while reading the directory.
  369.     Telldir(3) returns the current position associated with the named
  370.     directory stream for later use as an argument to seekdir(3).
  371.     Seekdir(3) sets the position of the next readdir(3) operation on
  372.     the named directory stream. The new position reverts to the one
  373.     associated with the directory stream when the telldir(3) operation
  374.     from which <loc> was obtained was performed.
  375.     Rewinddir(3) resets the position of the named directory stream to
  376.     the beginning of the directory. All buffered data for the directory
  377.     stream is discarded, thereby guaranteeing that the actual file
  378.     system directory will be referred to for the next readdir(3) on the
  379.     directory stream.
  380.     Closedir(3) closes the named directory stream; internal resources
  381.     used for the directory stream are liberated, and subsequent use of
  382.     the associated DIR object is no longer valid. Closedir(3) returns
  383.     a value of zero if no error occurs, -1 otherwise.  There are several
  384.     possible errors that can occur as a result of these operations; the
  385.     external integer variable <errno> is set to indicate the specific
  386.     error. (Readdir's detection of the normal end of a directory is not
  387.     considered to be an error.)
  388. EXAMPLE
  389.     Sample code which searches the current working directory for
  390.     an entry. Usage: "a.out directory filename".
  391.     #include <sys/types.h>
  392.     #include <dirent.h>
  393.     #include <stdio.h>
  394.     main( argc, argv )
  395.     int   argc;
  396.     char *argv[];
  397.     {
  398.     DIR *dirp;
  399.     struct dirent *dp;
  400.     if ( (dirp = opendir( argv[1] )) == NULL )
  401.         {
  402.         fprintf( stderr, "Cannot open directory\n" );
  403.         exit( 1 );
  404.         }
  405.     while ( (dp = readdir( dirp )) != NULL )
  406.         if ( strcmp( dp->d_name, argv[2] ) == 0 )
  407.         {
  408.         (void) closedir( dirp );
  409.         printf( "Found\n" );
  410.         exit( 0 );
  411.         }
  412.     (void) closedir( dirp );
  413.     printf( "Not found\n" );
  414.     exit( 1 );
  415.     }
  416. REFERENCES
  417.     dirent(4)
  418. WARNINGS
  419.     The value returned by telldir(3) need not have any simple
  420.     interpretation and should only be used as an argument to
  421.     seekdir(3). Similarly, the <loc> argument to seekdir(3) must
  422.     be obtained from a previous telldir(3) operation on the same
  423.     directory stream. Telldir(3) and seekdir(3) are unreliable
  424.     when the directory stream has been closed and reopened. It
  425.     is best to avoid using telldir(3) and seekdir(3) altogether.
  426.     The exact set of <errno> values and meanings may vary among
  427.     implementations.
  428.     Because directory entries can dynamically appear and disappear,
  429.     and because directory contents are buffered by these routines,
  430.     an application may need to continually rescan a directory to
  431.     maintain an accurate picture of its active entries.
  432. AUTHOR
  433.     Douglas A. Gwyn
  434.  
  435. #fclose
  436. NAME
  437.       fclose, fflush - close or flush a stream
  438. SYNTAX
  439.       #include <stdio.h>
  440.       int fclose (stream)
  441.       FILE *stream;
  442.       int fflush (stream)
  443.       FILE *stream;
  444. DESCRIPTION
  445.       Fclose causes    any buffered data for the named    stream to be
  446.       written out, and the stream to be closed.
  447.       Fclose is performed automatically for    all open files upon
  448.       calling exit(2).
  449.       Fflush causes    any buffered data for the named    stream to be
  450.       written to that file.     The stream remains open.
  451. DIAGNOSTICS
  452.       These    functions return 0 for success,    and EOF    if any error
  453.       (such    as trying to write to a    file that has not been opened
  454.       for writing) was detected.
  455. SEE ALSO
  456.       close(2), exit(2), fopen(3S),    setbuf(3S).
  457.                   
  458.  
  459. #ferror
  460. NAME
  461.       ferror, feof,    clearerr, fileno - stream status inquiries
  462. SYNTAX
  463.       #include <stdio.h>
  464.       int ferror (stream)
  465.       FILE *stream;
  466.       int feof (stream)
  467.       FILE *stream;
  468.       void clearerr    (stream)
  469.       FILE *stream;
  470.       int fileno (stream)
  471.       FILE *stream;
  472. DESCRIPTION
  473.       Ferror returns non-zero when an I/O error has    previously
  474.       occurred reading from    or writing to the named    stream,
  475.       otherwise zero.
  476.       Feof returns non-zero    when EOF has previously    been detected
  477.       reading the named input stream, otherwise zero.
  478.       Clearerr resets the error indicator and EOF indicator    to
  479.       zero on the named stream.
  480.       Fileno returns the integer file descriptor associated    with
  481.       the named stream; see    open(2).
  482.      NOTE
  483.       All these functions are implemented as macros; they cannot
  484.       be declared or redeclared.
  485. SEE ALSO
  486.       open(2), fopen(3S).
  487.                   
  488.  
  489. #fopen
  490. NAME
  491.       fopen, freopen, fdopen - open    a stream
  492. SYNTAX
  493.       #include <stdio.h>
  494.       FILE *fopen (file-name, type)
  495.       char *file-name, *type;
  496.       FILE *freopen    (file-name, type, stream)
  497.       char *file-name, *type;
  498.       FILE *stream;
  499.       FILE *fdopen (fildes,    type)
  500.       int fildes;
  501.       char *type;
  502. DESCRIPTION
  503.       Fopen    opens the file named by    file-name and associates a
  504.       stream with it.  Fopen returns a pointer to the FILE
  505.       structure associated with the    stream.
  506.       File-name points to a    character string that contains the
  507.       name of the file to be opened.
  508.       Type is a character string having one    of the following
  509.       values:
  510.            "r"     open for reading
  511.            "w"     truncate or create for    writing
  512.            "a"     append; open for writing at end of file, or
  513.              create    for writing
  514.            "r+"     open for update (reading and writing)
  515.            "w+"     truncate or create for    update
  516.            "a+"     append; open or create    for update at end-of-
  517.              file
  518.       Freopen substitutes the named    file in    place of the open
  519.       stream.  The original    stream is closed, regardless of
  520.       whether the open ultimately succeeds.     Freopen returns a
  521.       pointer to the FILE structure    associated with    stream.
  522.       Freopen is typically used to attach the preopened streams
  523.       associated with stdin, stdout    and stderr to other files.
  524.       Fdopen associates a stream with a file descriptor.  File
  525.       descriptors are obtained from    open, dup, creat, or pipe(2),
  526.                   
  527.       which    open files but do not return pointers to a FILE
  528.       structure stream. Streams are    necessary input    for many of
  529.       the Section 3S library routines.  The    type of    stream must
  530.       agree    with the mode of the open file.
  531.       When a file is opened    for update, both input and output may
  532.       be done on the resulting stream.  However, output may    not be
  533.       directly followed by input without an    intervening fseek or
  534.       rewind, and input may    not be directly    followed by output
  535.       without an intervening fseek,    rewind,    or an input operation
  536.       which    encounters end-of-file.
  537.       When a file is opened    for append (i.e., when type is "a" or
  538.       "a+"), it is impossible to overwrite information already in
  539.       the file.  Fseek may be used to reposition the file pointer
  540.       to any position in the file, but when    output is written to
  541.       the file, the    current    file pointer is    disregarded.  All
  542.       output is written at the end of the file and causes the file
  543.       pointer to be    repositioned at    the end    of the output.    If two
  544.       separate processes open the same file    for append, each
  545.       process may write freely to the file without fear of
  546.       destroying output being written by the other.     The output
  547.       from the two processes will be intermixed in the file    in the
  548.       order    in which it is written.
  549. SEE ALSO
  550.       creat(2), dup(2), open(2), pipe(2), fclose(3S), fseek(3S).
  551. DIAGNOSTICS
  552.       Fopen    and freopen return a NULL pointer on failure.
  553.  
  554. #fread
  555. NAME
  556.       fread, fwrite    - binary input/output
  557. SYNTAX
  558.       #include <stdio.h>
  559.       int fread (ptr, size,    nitems,    stream)
  560.       char *ptr;
  561.       int size, nitems;
  562.       FILE *stream;
  563.       int fwrite (ptr, size, nitems, stream)
  564.       char *ptr;
  565.       int size, nitems;
  566.       FILE *stream;
  567. DESCRIPTION
  568.       Fread    copies,    into an    array pointed to by ptr, nitems    items
  569.       of data from the named input stream, where an    item of    data
  570.       is a sequence    of bytes (not necessarily terminated by    a null
  571.       byte)    of length size.     Fread stops appending bytes if    an
  572.       end-of-file or error condition is encountered    while reading
  573.       stream, or if    nitems items have been read.  Fread leaves the
  574.       file pointer in stream, if defined, pointing to the byte
  575.       following the    last byte read if there    is one.     Fread does
  576.       not change the contents of stream.
  577.       Fwrite appends at most nitems    items of data from the array
  578.       pointed to by    ptr to the named output    stream.     Fwrite    stops
  579.       appending when it has    appended nitems    items of data or if an
  580.       error    condition is encountered on stream.  Fwrite does not
  581.       change the contents of the array pointed to by ptr.
  582.       The argument size is typically sizeof(*ptr) where the
  583.       pseudo-function sizeof specifies the length of an item
  584.       pointed to by    ptr.  If ptr points to a data type other than
  585.       char it should be cast into a    pointer    to char.
  586. SEE ALSO
  587.       read(2), write(2), fopen(3S),    getc(3S), gets(3S),
  588.       printf(3S), putc(3S),    puts(3S), scanf(3S).
  589. DIAGNOSTICS
  590.       Fread    and fwrite return the number of    items read or written.
  591.       If size or nitems is non-positive, no    characters are read or
  592.       written and 0    is returned by both fread and fwrite.
  593. BUGS
  594.       On the PDP-11    and iAPX286, the number    of bytes transferred
  595.       is the product of size and nitems, modulo 65536.
  596.                   
  597.  
  598. #fseek
  599. NAME
  600.       fseek, rewind, ftell - reposition a file pointer in a    stream
  601. SYNTAX
  602.       #include <stdio.h>
  603.       int fseek (stream, offset, ptrname)
  604.       FILE *stream;
  605.       long offset;
  606.       int ptrname;
  607.       void rewind (stream)
  608.       FILE *stream;
  609.       long ftell (stream)
  610.       FILE *stream;
  611. DESCRIPTION
  612.       Fseek    sets the position of the next input or output
  613.       operation on the stream.  The    new position is    at the signed
  614.       distance offset bytes    from the beginning, from the current
  615.       position, or from the    end of the file, according as ptrname
  616.       has the value    0, 1, or 2.
  617.       Rewind(stream) is equivalent to fseek(stream,    0L, 0),    except
  618.       that no value    is returned.
  619.       Fseek    and rewind undo    any effects of ungetc(3S).
  620.       After    fseek or rewind, the next operation on a file opened
  621.       for update may be either input or output.
  622.       Ftell    returns    the offset of the current byte relative    to the
  623.       beginning of the file    associated with    the named stream.
  624. SEE ALSO
  625.       lseek(2), fopen(3S), popen(3S), ungetc(3S).
  626. DIAGNOSTICS
  627.       Fseek    returns    non-zero for improper seeks, otherwise zero.
  628.       An improper seek can be, for example,    an fseek done on a
  629.       file that has    not been opened    via fopen; in particular,
  630.       fseek    may not    be used    on a terminal, or on a file opened via
  631.       popen(3S).
  632.      WARNING
  633.       Although on the UNIX system an offset    returned by ftell is
  634.       measured in bytes, and it is permissible to seek to
  635.       positions relative to    that offset, portability to non-UNIX
  636.       systems requires that    an offset be used by fseek directly.
  637.       Arithmetic may not meaningfully be performed on such an
  638.       offset, which    is not necessarily measured in bytes.
  639.                   
  640.  
  641. #ftype
  642. NAME
  643.       int, ifix, idint, real, float, sngl, dble, cmplx, dcmplx,
  644.       ichar, char -    explicit FORTRAN type conversion
  645. SYNTAX
  646.       integer i, j
  647.       real r, s
  648.       double precision dp, dq
  649.       complex cx
  650.       double complex dcx
  651.       character*1 ch
  652.       i = int(r)
  653.       i = int(dp)
  654.       i = int(cx)
  655.       i = int(dcx)
  656.       i = ifix(r)
  657.       i = idint(dp)
  658.       r = real(i)
  659.       r = real(dp)
  660.       r = real(cx)
  661.       r = real(dcx)
  662.       r = float(i)
  663.       r = sngl(dp)
  664.       dp = dble(i)
  665.       dp = dble(r)
  666.       dp = dble(cx)
  667.       dp = dble(dcx)
  668.       cx = cmplx(i)
  669.       cx = cmplx(i,    j)
  670.       cx = cmplx(r)
  671.       cx = cmplx(r,    s)
  672.       cx = cmplx(dp)
  673.       cx = cmplx(dp, dq)
  674.       cx = cmplx(dcx)
  675.       dcx =    dcmplx(i)
  676.       dcx =    dcmplx(i, j)
  677.       dcx =    dcmplx(r)
  678.       dcx =    dcmplx(r, s)
  679.       dcx =    dcmplx(dp)
  680.       dcx =    dcmplx(dp, dq)
  681.       dcx =    dcmplx(cx)
  682.       i = ichar(ch)
  683.       ch = char(i)
  684. DESCRIPTION
  685.       These    functions perform conversion from one data type    to
  686.                   
  687.       another.
  688.       The function int converts to integer form its    real, double
  689.       precision, complex, or double    complex    argument.  If the
  690.       argument is real or double precision,    int returns the
  691.       integer whose    magnitude is the largest integer that does not
  692.       exceed the magnitude of the argument and whose sign is the
  693.       same as the sign of the argument (i.e., truncation). For
  694.       complex types, the above rule    is applied to the real part.
  695.       ifix and idint convert only real and double precision
  696.       arguments respectively.
  697.       The function real converts to    real form an integer, double
  698.       precision, complex, or double    complex    argument.  If the
  699.       argument is double precision or double complex, as much
  700.       precision is kept as is possible. If the argument is one of
  701.       the complex types, the real part is returned.     float and
  702.       sngl convert only integer and    double precision arguments
  703.       respectively.
  704.       The function dble converts any integer, real,    complex, or
  705.       double complex argument to double precision form.  If    the
  706.       argument is of a complex type, the real part is returned.
  707.       The function cmplx converts its integer, real, double
  708.       precision, or    double complex argument(s) to complex form.
  709.       The function dcmplx converts to double complex form its
  710.       integer, real, double    precision, or complex argument(s).
  711.       Either one or    two arguments may be supplied to cmplx and
  712.       dcmplx . If there is only one    argument, it is    taken as the
  713.       real part of the complex type    and an imaginary part of zero
  714.       is supplied. If two arguments    are supplied, the first    is
  715.       taken    as the real part and the second    as the imaginary part.
  716.       The function ichar converts from a character to an integer
  717.       depending on the character's position    in the collating
  718.       sequence.
  719.       The function char returns the    character in the ith position
  720.       in the processor collating sequence where i is the supplied
  721.       argument.
  722.       For a    processor capable of representing n characters,
  723.       ichar(char(i)) = i for 0 < i < n, and
  724.       char(ichar(ch)) = ch for any representable character ch.
  725.  
  726. #getarg
  727. NAME
  728.       getarg - return FORTRAN command-line argument
  729. SYNTAX
  730.       character*N c
  731.       integer i
  732.       getarg(i, c)
  733. DESCRIPTION
  734.       Getarg returns the i-th command-line argument    of the current
  735.       process. Thus, if a program were invoked via
  736.            foo arg1    arg2 arg3
  737.       getarg(2, c) would return the    string ``arg2''    in the
  738.       character variable c.
  739. SEE ALSO
  740.       getopt(3C).
  741.                   
  742.  
  743. #getc
  744. NAME
  745.       getc,    getchar, fgetc,    getw - get character or    word from a
  746.       stream
  747. SYNTAX
  748.       #include <stdio.h>
  749.       int getc (stream)
  750.       FILE *stream;
  751.       int getchar ()
  752.       int fgetc (stream)
  753.       FILE *stream;
  754.       int getw (stream)
  755.       FILE *stream;
  756. DESCRIPTION
  757.       Getc returns the next    character (i.e., byte) from the    named
  758.       input    stream,    as an integer.    It also    moves the file
  759.       pointer, if defined, ahead one character in stream.  Getchar
  760.       is defined as    getc(stdin).  Getc and getchar are macros.
  761.       Fgetc    behaves    like getc, but is a function rather than a
  762.       macro.  Fgetc    runs more slowly than getc, but    it takes less
  763.       space    per invocation and its name can    be passed as an
  764.       argument to a    function.
  765.       Getw returns the next    word (i.e., integer) from the named
  766.       input    stream.     Getw increments the associated    file pointer,
  767.       if defined, to point to the next word.  The size of a    word
  768.       is the size of an integer and    varies from machine to
  769.       machine.  Getw assumes no special alignment in the file.
  770. SEE ALSO
  771.       fclose(3S), ferror(3S), fopen(3S), fread(3S),    gets(3S),
  772.       putc(3S), scanf(3S).
  773. DIAGNOSTICS
  774.       These    functions return the constant EOF at end-of-file or
  775.       upon an error.  Because EOF is a valid integer, ferror(3S)
  776.       should be used to detect getw    errors.
  777.      WARNING
  778.       If the integer value returned    by getc, getchar, or fgetc is
  779.       stored into a    character variable and then compared against
  780.       the integer constant EOF, the    comparison may never succeed,
  781.       because sign-extension of a character    on widening to integer
  782.       is machine-dependent.
  783. BUGS
  784.                   
  785.       Because it is    implemented as a macro,    getc treats
  786.       incorrectly a    stream argument    with side effects.  In
  787.       particular, getc(*f++) does not work sensibly.  Fgetc    should
  788.       be used instead.
  789.       Because of possible differences in word length and byte
  790.       ordering, files written using    putw are machine-dependent,
  791.       and may not be read using getw on a different    processor.
  792.  
  793. #getdents
  794. SUBROUTINES
  795.     getdents(3)         - get directory entries
  796. INVOCATION
  797.     int getdents( fildes, buf, nbyte )
  798.       int fildes;
  799.       char *buf;
  800.       unsigned nbyte;
  801.   
  802. EXPLANATION
  803.     Getdents(3) reads directory entries in a file system independent
  804.     format. This routine is only used by readdir(3) and should
  805.     never be used directly by a user's program.
  806. REFERENCES
  807.     directory(3), dirent(4)
  808.  
  809. #getenv
  810. NAME
  811.       getenv - return value    for environment    name
  812. SYNTAX
  813.       char *getenv (name)
  814.       char *name;
  815. DESCRIPTION
  816.       Getenv searches the environment list [see environ(5)]    for a
  817.       string of the    form name=value, and returns a pointer to the
  818.       value    in the current environment if such a string is
  819.       present, otherwise a NULL pointer.
  820. SEE ALSO
  821.       exec(2), putenv(3C), environ(5).
  822.                   
  823. NAME
  824.       getenv - return FORTRAN environment variable
  825. SYNTAX
  826.       character*N c
  827.       getenv( TMPDIR , c)
  828. DESCRIPTION
  829.       Getenv returns the character-string value of the environment
  830.       variable represented by its first argument into the
  831.       character variable of    its second argument.  If no such
  832.       environment variable exists, all blanks will be returned.
  833. SEE ALSO
  834.       getenv(3C), environ(5).
  835.                   
  836.  
  837. #getopt
  838. NAME
  839.       getopt - get option letter from argument vector
  840. SYNTAX
  841.       int getopt (argc, argv, optstring)
  842.       int argc;
  843.       char **argv, *opstring;
  844.       extern char *optarg;
  845.       extern int optind, opterr;
  846. DESCRIPTION
  847.       Getopt returns the next option letter    in argv    that matches a
  848.       letter in optstring.    Optstring is a string of recognized
  849.       option letters; if a letter is followed by a colon, the
  850.       option is expected to    have an    argument that may or may not
  851.       be separated from it by white    space.    Optarg is set to point
  852.       to the start of the option argument on return    from getopt.
  853.       Getopt places    in optind the argv index of the    next argument
  854.       to be    processed.  Because optind is external,    it is normally
  855.       initialized to zero automatically before the first call to
  856.       getopt.
  857.       When all options have    been processed (i.e., up to the    first
  858.       non-option argument),    getopt returns EOF.  The special
  859.       option -- may    be used    to delimit the end of the options; EOF
  860.       will be returned, and    -- will    be skipped.
  861. DIAGNOSTICS
  862.       Getopt prints    an error message on stderr and returns a
  863.       question mark    (?)  when it encounters    an option letter not
  864.       included in optstring.  This error message may be disabled
  865.       by setting opterr to a non-zero value.
  866.      EXAMPLE
  867.       The following    code fragment shows how    one might process the
  868.       arguments for    a command that can take    the mutually exclusive
  869.       options a and    b, and the options f and o, both of which
  870.       require arguments:
  871.            main (argc, argv)
  872.            int argc;
  873.            char **argv;
  874.            {
  875.             int    c;
  876.             extern char    *optarg;
  877.             extern int optind;
  878.             .
  879.             .
  880.             .
  881.             while ((c =    getopt(argc, argv, "abf:o:")) != EOF)
  882.                   
  883.              switch    (c) {
  884.              case 'a':
  885.                   if (bflg)
  886.                    errflg++;
  887.                   else
  888.                    aflg++;
  889.                   break;
  890.              case 'b':
  891.                   if (aflg)
  892.                    errflg++;
  893.                   else
  894.                    bproc( );
  895.                   break;
  896.              case 'f':
  897.                   ifile = optarg;
  898.                   break;
  899.              case 'o':
  900.                   ofile = optarg;
  901.                   break;
  902.              case '?':
  903.                   errflg++;
  904.              }
  905.             if (errflg)    {
  906.              fprintf(stderr, "usage: . . . ");
  907.              exit (2);
  908.             }
  909.             for    ( ; optind < argc; optind++) {
  910.              if (access(argv[optind], 4)) {
  911.             .
  912.             .
  913.             .
  914.            }
  915. SEE ALSO
  916.       getopt(1) in the UNIX    System V User Reference    Manual.
  917.  
  918. #getpass
  919. NAME
  920.       getpass - read a password
  921. SYNTAX
  922.       char *getpass    (prompt)
  923.       char *prompt;
  924. DESCRIPTION
  925.       Getpass reads    up to a    newline    or EOF from the    file /dev/tty,
  926.       after    prompting on the standard error    output with the    null-
  927.       terminated string prompt and disabling echoing.  A pointer
  928.       is returned to a null-terminated string of at    most 8
  929.       characters.  If /dev/tty cannot be opened, a NULL pointer is
  930.       returned.  An    interrupt will terminate input and send    an
  931.       interrupt signal to the calling program before returning.
  932. FILES
  933.       /dev/tty
  934. SEE ALSO
  935.       crypt(3C).
  936.      WARNING
  937.       The above routine uses <stdio.h>, which causes it to
  938.       increase the size of programs    not otherwise using standard
  939.       I/O, more than might be expected.
  940. BUGS
  941.       The return value points to static data whose content is
  942.       overwritten by each call.
  943.                   
  944.  
  945. #getpw
  946. NAME
  947.       getpw    - get name from    UID
  948. SYNTAX
  949.       int getpw (uid, buf)
  950.       int uid;
  951.       char *buf;
  952. DESCRIPTION
  953.       Getpw    searches the password file for a user id number    that
  954.       equals uid, copies the line of the password file in which
  955.       uid was found    into the array pointed to by buf, and returns
  956.       0.  Getpw returns non-zero if    uid cannot be found.
  957.       This routine is included only    for compatibility with prior
  958.       systems and should not be used; see getpwent(3C) for
  959.       routines to use instead.
  960. FILES
  961.       /etc/passwd
  962. SEE ALSO
  963.       getpwent(3C),    passwd(4).
  964. DIAGNOSTICS
  965.       Getpw    returns    non-zero on error.
  966.      WARNING
  967.       The above routine uses <stdio.h>, which causes it to
  968.       increase, more than might be expected, the size of programs
  969.       not otherwise    using standard I/O.
  970.                   
  971.  
  972. #gets
  973. NAME
  974.       gets,    fgets -    get a string from a stream
  975. SYNTAX
  976.       #include <stdio.h>
  977.       char *gets (s)
  978.       char *s;
  979.       char *fgets (s, n, stream)
  980.       char *s;
  981.       int n;
  982.       FILE *stream;
  983. DESCRIPTION
  984.       Gets reads characters    from the standard input    stream,    stdin,
  985.       into the array pointed to by s, until    a new-line character
  986.       is read or an    end-of-file condition is encountered.  The
  987.       new-line character is    discarded and the string is terminated
  988.       with a null character.
  989.       Fgets    reads characters from the stream into the array
  990.       pointed to by    s, until n-1 characters    are read, or a new-
  991.       line character is read and transferred to s, or an end-of-
  992.       file condition is encountered.  The string is    then
  993.       terminated with a null character.
  994. SEE ALSO
  995.       ferror(3S), fopen(3S), fread(3S), getc(3S), scanf(3S).
  996. DIAGNOSTICS
  997.       If end-of-file is encountered    and no characters have been
  998.       read,    no characters are transferred to s and a NULL pointer
  999.       is returned.    If a read error    occurs,    such as    trying to use
  1000.       these    functions on a file that has not been opened for
  1001.       reading, a NULL pointer is returned.    Otherwise s is
  1002.       returned.
  1003.                   
  1004.  
  1005. #getut
  1006. NAME
  1007.       getutent, getutid, getutline,    pututline, setutent, endutent,
  1008.       utmpname - access utmp file entry
  1009. SYNTAX
  1010.       #include <utmp.h>
  1011.       struct utmp *getutent    ( )
  1012.       struct utmp *getutid (id)
  1013.       struct utmp *id;
  1014.       struct utmp *getutline (line)
  1015.       struct utmp *line;
  1016.       void pututline (utmp)
  1017.       struct utmp *utmp;
  1018.       void setutent    ( )
  1019.       void endutent    ( )
  1020.       void utmpname    (file)
  1021.       char *file;
  1022. DESCRIPTION
  1023.       Getutent, getutid and    getutline each return a    pointer    to a
  1024.       structure of the following type:
  1025.            struct utmp {
  1026.               char     ut_user[8];        /* User login name */
  1027.               char     ut_id[4];        /* /etc/inittab id
  1028.                              * (usually    line #)    */
  1029.               char     ut_line[12];        /* device name (console,
  1030.                              * lnxx) */
  1031.               short     ut_pid;        /* process id */
  1032.               short     ut_type;        /* type of entry */
  1033.               struct     exit_status {
  1034.               short         e_termination; /* Process termination status */
  1035.               short         e_exit;        /* Process exit status */
  1036.               }    ut_exit;            /* The exit    status of a process
  1037.                              * marked as DEAD_PROCESS. */
  1038.               time_t     ut_time;        /* time entry was made */
  1039.            };
  1040.       Getutent reads in the    next entry from    a utmp-like file.  If
  1041.       the file is not already open,    it opens it.  If it reaches
  1042.       the end of the file, it fails.
  1043.       Getutid searches forward from    the current point in the utmp
  1044.       file until it    finds an entry with a ut_type matching
  1045.       id->ut_type if the type specified is RUN_LVL,    BOOT_TIME,
  1046.                   
  1047.       OLD_TIME or NEW_TIME.     If the    type specified in id is
  1048.       INIT_PROCESS,    LOGIN_PROCESS, USER_PROCESS or DEAD_PROCESS,
  1049.       then getutid will return a pointer to    the first entry    whose
  1050.       type is one of these four and    whose ut_id field matches
  1051.       id->ut_id.  If the end of file is reached without a match,
  1052.       it fails.
  1053.       Getutline searches forward from the current point in the
  1054.       utmp file until it finds an entry of the type    LOGIN_PROCESS
  1055.       or USER_PROCESS which    also has a ut_line string matching the
  1056.       line->ut_line    string.     If the    end of file is reached without
  1057.       a match, it fails.
  1058.       Pututline writes out the supplied utmp structure into    the
  1059.       utmp file.  It uses getutid to search    forward    for the    proper
  1060.       place    if it finds that it is not already at the proper
  1061.       place.  It is    expected that normally the user    of pututline
  1062.       will have searched for the proper entry using    one of the
  1063.       getut    routines.  If so, pututline will not search.  If
  1064.       pututline does not find a matching slot for the new entry,
  1065.       it will add a    new entry to the end of    the file.
  1066.       Setutent resets the input stream to the beginning of the
  1067.       file.     This should be    done before each search    for a new
  1068.       entry    if it is desired that the entire file be examined.
  1069.       Endutent closes the currently    open file.
  1070.       Utmpname allows the user to change the name of the file
  1071.       examined, from /etc/utmp to any other    file.  It is most
  1072.       often    expected that this other file will be /etc/wtmp.  If
  1073.       the file does    not exist, this    will not be apparent until the
  1074.       first    attempt    to reference the file is made.    Utmpname does
  1075.       not open the file.  It just closes the old file if it    is
  1076.       currently open and saves the new file    name.
  1077. FILES
  1078.       /etc/utmp
  1079.       /etc/wtmp
  1080. SEE ALSO
  1081.       ttyslot(3C), utmp(4).
  1082. DIAGNOSTICS
  1083.       A NULL pointer is returned upon failure to read, whether for
  1084.       permissions or having    reached    the end    of file, or upon
  1085.       failure to write.
  1086.      COMMENTS
  1087.       The most current entry is saved in a static structure.
  1088.       Multiple accesses require that it be copied before further
  1089.       accesses are made.  Each call    to either getutid or getutline
  1090.       sees the routine examine the static structure    before
  1091.       performing more I/O.    If the contents    of the static
  1092.       structure match what it is searching for, it looks no
  1093.       further.  For    this reason to use getutline to    search for
  1094.       multiple occurrences,    it would be necessary to zero out the
  1095.       static after each success, or    getutline would    just return
  1096.       the same pointer over    and over again.     There is one
  1097.       exception to the rule    about removing the structure before
  1098.       further reads    are done.  The implicit    read done by pututline
  1099.       (if it finds that it is not already at the correct place in
  1100.       the file) will not hurt the contents of the static structure
  1101.       returned by the getutent, getutid or getutline routines, if
  1102.       the user has just modified those contents and    passed the
  1103.       pointer back to pututline.
  1104.       These    routines use buffered standard I/O for input, but
  1105.       pututline uses an unbuffered non-standard write to avoid
  1106.       race conditions between processes trying to modify the utmp
  1107.       and wtmp files.
  1108.  
  1109. #index
  1110. NAME
  1111.       index    - return location of FORTRAN substring
  1112. SYNTAX
  1113.       character*N1 ch1
  1114.       character*N2 ch2
  1115.       integer i
  1116.       i = index (ch1, ch2)
  1117. DESCRIPTION
  1118.       Index    returns    the location of    substring ch2 in string    ch1.
  1119.       The value returned is    the position at    which substring    ch2
  1120.       starts, or 0 is it is    not present in string ch1.
  1121.                   
  1122.  
  1123. #lock
  1124. While re-reading Advanced Unix Programming by Marc J. Rochkind, I ran
  1125. across some routines that I thought others might find useful.
  1126. ------------------------------------------------------------------------------
  1127. The lock and unlock functions can be used like this:
  1128.         if (lock("database")) {
  1129.         ... manipulate database...
  1130.         unlock("database");
  1131.         }
  1132.         else
  1133.         ...couldn't obtain lock...
  1134. The name "database" is abstract, it could have been called anything.
  1135. If two or more processes are concurrentlyu executing this code, the lock will
  1136. prevent them from simultaneously executing the protected section(manipulate
  1137. database). All processes would have to call the lock function for this to
  1138. work though.
  1139. As an enhancement you could write the pid and time on the file so other
  1140. processes could see who has it and for how long.(If this is done the permis-
  1141. sions should be set to octal 444 instead of 0).
  1142. ------------------------------------------------------------------------------
  1143. Statutil.c is a program that allows you to do several different functions on
  1144. files;
  1145.     change modification time, owner, permissions
  1146.     display type of file(dir, ordinary, block, character)
  1147.         device number(major, minor), number of links to file,
  1148.         I-node number, Size, group id, owner, last mod. time
  1149. All done interactively.
  1150.  
  1151. #lockf
  1152. NAME
  1153.       lockf    - record locking on files
  1154. SYNTAX
  1155.       # include <unistd.h>
  1156.       lockf    (fildes, function, size) long size; int    fildes,
  1157.       function;
  1158. DESCRIPTION
  1159.       The lockf command will allow sections    of a file to be    locked
  1160.       (advisory write locks).  (Mandatory or enforcement mode
  1161.       record locks are not currently available.)  Locking calls
  1162.       from other processes which attempt to    lock the locked    file
  1163.       section will either return an    error value or be put to sleep
  1164.       until    the resource becomes unlocked.    All the    locks for a
  1165.       process are removed when the process terminates.  See
  1166.       fcntl(2) for more information    about record locking.
  1167.       Fildes is an open file descriptor.  The file descriptor must
  1168.       have O_WRONLY    or O_RDWR permission in    order to establish
  1169.       lock with this function call.
  1170.       Function is a    control    value which specifies the action to be
  1171.       taken.  The permissible values for function are defined in
  1172.       <unistd.h> as    follows:
  1173.       #define   F_ULOCK   0      /* Unlock a previously locked    section    */
  1174.       #define   F_LOCK    1      /* Lock a section for    exclusive use */
  1175.       #define   F_TLOCK   2      /* Test and lock a section for exclusive use */
  1176.       #define   F_TEST    3      /* Test section for other processes locks */
  1177.       All other values of function are reserved for    future
  1178.       extensions and will result in    an error return    if not
  1179.       implemented.
  1180.       F_TEST is used to detect if a    lock by    another    process    is
  1181.       present on the specified section.  F_LOCK and    F_TLOCK    both
  1182.       lock a section of a file if the section is available.
  1183.       F_UNLOCK removes locks from a    section    of the file.
  1184.       Size is the number of    contiguous bytes to be locked or
  1185.       unlocked.  The resource to be    locked starts at the current
  1186.       offset in the    file and extends forward for a positive    size
  1187.       and backward for a negative size (the    preceding bytes    up to
  1188.       but not including the    current    offset).  If size is zero, the
  1189.       section from the current offset through the largest file
  1190.       offset is locked (i.e., from the current offset through the
  1191.       present or any future    end-of-file).  An area need not    be
  1192.       allocated to the file    in order to be locked, as such locks
  1193.       may exist past the end-of-file.
  1194.                   
  1195.       The sections locked with F_LOCK or F_TLOCK may, in whole or
  1196.       in part, contain or be contained by a    previously locked
  1197.       section for the same process.     When this occurs, or if
  1198.       adjacent sections occur, the sections    are combined into a
  1199.       single section.  If the request requires that    a new element
  1200.       be added to the table    of active locks    and this table is
  1201.       already full,    an error is returned, and the new section is
  1202.       not locked.
  1203.       F_LOCK and F_TLOCK requests differ only by the action    taken
  1204.       if the resource is not available.  F_LOCK will cause the
  1205.       calling process to sleep until the resource is available.
  1206.       F_TLOCK will cause the function to return a -1 and set errno
  1207.       to [EACCESS] error if    the section is already locked by
  1208.       another process.
  1209.       F_ULOCK requests may,    in whole or in part, release one or
  1210.       more locked sections controlled by the process.  When
  1211.       sections are not fully released, the remaining sections are
  1212.       still    locked by the process.    Releasing the center section
  1213.       of a locked section requires an additional element in    the
  1214.       table    of active locks.  If this table    is full, an [EDEADLK]
  1215.       error    is returned and    the requested section is not released.
  1216.       A potential for deadlock occurs if a process controlling a
  1217.       locked resource is put to sleep by accessing another
  1218.       process's locked resource.  Thus calls to lock or fcntl scan
  1219.       for a    deadlock prior to sleeping on a    locked resource.  An
  1220.       error    return is made if sleeping on the locked resource
  1221.       would    cause a    deadlock.
  1222.       Sleeping on a    resource is interrupted    with any signal.  The
  1223.       alarm(2) command may be used to provide a timeout facility
  1224.       in applications which    require    this facility.
  1225.       The lockf utility will fail if one or    more of    the following
  1226.       are true:
  1227.       [EBADF]
  1228.            Fildes is not a valid open descriptor.
  1229.       [EACCESS]
  1230.            Cmd is F_TLOCK or F_TEST    and the    section    is already
  1231.            locked by another process.
  1232.       [EDEADLK]
  1233.            Cmd is F_LOCK or    F_TLOCK    and a deadlock would occur.
  1234.            Also the    cmd is either of the above or F_ULOCK and the
  1235.            number of entries in the    lock table would exceed    the
  1236.            number allocated    on the system.
  1237. SEE ALSO
  1238.       alarm(2), close(2), creat(2),    fcntl(2), intro(2), open(2),
  1239.       read(2), write(2).
  1240.      RETURN VALUE
  1241.       Upon successful completion, a    value of 0 is returned.
  1242.       Otherwise, a value of    -1 is returned and errno is set    to
  1243.       indicate the error.
  1244.      CAVEATS
  1245.       Unexpected results may occur in processes that do buffering
  1246.       in the user address space.  The process may later read/write
  1247.       data which is/was locked.  The standard I/O package is the
  1248.       most common source of    unexpected buffering.
  1249.  
  1250. #logname
  1251. NAME
  1252.       logname - return login name of user
  1253. SYNTAX
  1254.       char *logname( )
  1255. DESCRIPTION
  1256.       Logname returns a pointer to the null-terminated login name;
  1257.       it extracts the $LOGNAME variable from the user's
  1258.       environment.
  1259.       This routine is kept in /lib/libPW.a.
  1260. FILES
  1261.       /etc/profile
  1262. SEE ALSO
  1263.       profile(4), environ(5).
  1264.       env(1), login(1) in the UNIX System V    User Reference Manual.
  1265. BUGS
  1266.       The return values point to static data whose content is
  1267.       overwritten by each call.
  1268.       This method of determining a login name is subject to
  1269.       forgery.
  1270.                   
  1271.  
  1272. #lrand
  1273. SUBROUTINES
  1274.     lrand(3)        - lehmer random number generator
  1275. INVOCATION
  1276.     long seed( lseed )
  1277.       long lseed;
  1278.     long lrand()
  1279. EXPLANATION
  1280.     Lrand(3) uses a prime modulus multiplicative linear
  1281.     congruential generator (PMMLCG) to generate a pseudo-
  1282.     random number in the range 1 to 2147483646 {LONG_MAX}-1.
  1283.     The generator is much more random than rand(3), especially
  1284.     in the low order bits. The formula used is:
  1285.       seed = (16807 * seed) % 2147483647
  1286.     Seed(3) sets the seed to an initial value, the default
  1287.     is 1.
  1288. RESULTS
  1289.     Lrand(3) returns the next value of seed.
  1290.     Seed(3) returns the previous value of seed.
  1291. REFERENCES
  1292.     rand(3)
  1293.  
  1294. #malloc
  1295. NAME
  1296.       malloc, free,    realloc, calloc    - main memory allocator
  1297. SYNTAX
  1298.       char *malloc (size)
  1299.       unsigned size;
  1300.       void free (ptr)
  1301.       char *ptr;
  1302.       char *realloc    (ptr, size)
  1303.       char *ptr;
  1304.       unsigned size;
  1305.       char *calloc (nelem, elsize)
  1306.       unsigned nelem, elsize;
  1307. DESCRIPTION
  1308.       Malloc and free provide a simple general-purpose memory
  1309.       allocation package.  Malloc returns a    pointer    to a block of
  1310.       at least size    bytes suitably aligned for any use.
  1311.       The argument to free is a pointer to a block previously
  1312.       allocated by malloc; after free is performed this space is
  1313.       made available for further allocation, but its contents are
  1314.       left undisturbed.
  1315.       Undefined results will occur if the space assigned by    malloc
  1316.       is overrun or    if some    random number is handed    to free.
  1317.       Malloc allocates the first big enough    contiguous reach of
  1318.       free space found in a    circular search    from the last block
  1319.       allocated or freed, coalescing adjacent free blocks as it
  1320.       searches.  It    calls sbrk [see    brk(2)]    to get more memory
  1321.       from the system when there is    no suitable space already
  1322.       free.
  1323.       Realloc changes the size of the block    pointed    to by ptr to
  1324.       size bytes and returns a pointer to the (possibly moved)
  1325.       block.  The contents will be unchanged up to the lesser of
  1326.       the new and old sizes.  If no    free block of size bytes is
  1327.       available in the storage arena, then realloc will ask    malloc
  1328.       to enlarge the arena by size bytes and will then move    the
  1329.       data to the new space.
  1330.       Realloc also works if    ptr points to a    block freed since the
  1331.       last call of malloc, realloc,    or calloc; thus    sequences of
  1332.       free,    malloc and realloc can exploit the search strategy of
  1333.       malloc to do storage compaction.
  1334.       Calloc allocates space for an    array of nelem elements    of
  1335.       size elsize.    The space is initialized to zeros.
  1336.                   
  1337.       Each of the allocation routines returns a pointer to space
  1338.       suitably aligned (after possible pointer coercion) for
  1339.       storage of any type of object.
  1340. SEE ALSO
  1341.       brk(2), malloc(3X).
  1342. DIAGNOSTICS
  1343.       Malloc, realloc and calloc return a NULL pointer if there is
  1344.       no available memory or if the    arena has been detectably
  1345.       corrupted by storing outside the bounds of a block.  When
  1346.       this happens the block pointed to by ptr may be destroyed.
  1347.      NOTE
  1348.       Search time increases    when many objects have been allocated;
  1349.       that is, if a    program    allocates but never frees, then    each
  1350.       successive allocation    takes longer.  For an alternate, more
  1351.       flexible implementation, see malloc(3X).
  1352. NAME
  1353.       malloc, free,    realloc, calloc, mallopt, mallinfo - fast main
  1354.       memory allocator
  1355. SYNTAX
  1356.       #include <malloc.h>
  1357.       char *malloc (size)
  1358.       unsigned size;
  1359.       void free (ptr)
  1360.       char *ptr;
  1361.       char *realloc    (ptr, size)
  1362.       char *ptr;
  1363.       unsigned size;
  1364.       char *calloc (nelem, elsize)
  1365.       unsigned nelem, elsize;
  1366.       int mallopt (cmd, value)
  1367.       int cmd, value;
  1368.       struct mallinfo mallinfo (max)
  1369.       int max;
  1370. DESCRIPTION
  1371.       Malloc and free provide a simple general-purpose memory
  1372.       allocation package, which runs considerably faster than the
  1373.       malloc(3C) package.  It is found in the library ``malloc'',
  1374.       and is loaded    if the option ``-lmalloc'' is used with    cc(1)
  1375.       or ld(1).
  1376.       Malloc returns a pointer to a    block of at least size bytes
  1377.       suitably aligned for any use.
  1378.       The argument to free is a pointer to a block previously
  1379.       allocated by malloc; after free is performed this space is
  1380.       made available for further allocation, and its contents have
  1381.       been destroyed (but see mallopt below    for a way to change
  1382.       this behavior).
  1383.       Undefined results will occur if the space assigned by    malloc
  1384.       is overrun or    if some    random number is handed    to free.
  1385.       Realloc changes the size of the block    pointed    to by ptr to
  1386.       size bytes and returns a pointer to the (possibly moved)
  1387.       block.  The contents will be unchanged up to the lesser of
  1388.       the new and old sizes.
  1389.       Calloc allocates space for an    array of nelem elements    of
  1390.       size elsize.    The space is initialized to zeros.
  1391.                   
  1392.       Mallopt provides for control over the    allocation algorithm.
  1393.       The available    values for cmd are:
  1394.       M_MXFAST Set maxfast to value.  The algorithm    allocates all
  1395.            blocks below    the size of maxfast in large groups
  1396.            and then doles them out very    quickly.  The default
  1397.            value for maxfast is    0.
  1398.       M_NLBLKS Set numlblks    to value.  The above mentioned ``large
  1399.            groups'' each contain numlblks blocks. Numlblks
  1400.            must    be greater than    0.  The    default    value for
  1401.            numlblks is 100.
  1402.       M_GRAIN  Set grain to    value.    The sizes of all blocks
  1403.            smaller than    maxfast    are considered to be rounded
  1404.            up to the nearest multiple of grain.     Grain must be
  1405.            greater than    0.  The    default    value of grain is the
  1406.            smallest number of bytes which will allow alignment
  1407.            of any data type.  Value will be rounded up to a
  1408.            multiple of the default when    grain is set.
  1409.       M_KEEP   Preserve data in a freed block until    the next
  1410.            malloc, realloc, or calloc.    This option is
  1411.            provided only for compatibility with    the old
  1412.            version of malloc and is not    recommended.
  1413.       These    values are defined in the <malloc.h> header file.
  1414.       Mallopt may be called    repeatedly, but    may not    be called
  1415.       after    the first small    block is allocated.
  1416.       Mallinfo provides instrumentation describing space usage.
  1417.       It returns the structure:
  1418.       struct mallinfo  {
  1419.           int arena;        /* total space in arena */
  1420.           int ordblks;        /* number of ordinary blocks */
  1421.           int smblks;        /* number of small blocks */
  1422.           int hblkhd;        /* space in    holding    block headers */
  1423.           int hblks;        /* number of holding blocks    */
  1424.           int usmblks;        /* space in    small blocks in    use */
  1425.           int fsmblks;        /* space in    free small blocks */
  1426.           int uordblks;        /* space in    ordinary blocks    in use */
  1427.           int fordblks;        /* space in    free ordinary blocks */
  1428.           int keepcost;        /* space penalty if    keep option */
  1429.                     /* is used */
  1430.       }
  1431.       This structure is defined in the <malloc.h> header file.
  1432.       Each of the allocation routines returns a pointer to space
  1433.       suitably aligned (after possible pointer coercion) for
  1434.       storage of any type of object.
  1435. SEE ALSO
  1436.       brk(2), malloc(3C).
  1437. DIAGNOSTICS
  1438.       Malloc, realloc and calloc return a NULL pointer if there is
  1439.       not enough available memory.    When realloc returns NULL, the
  1440.       block    pointed    to by ptr is left intact.  If mallopt is
  1441.       called after any allocation or if cmd    or value are invalid,
  1442.       non-zero is returned.     Otherwise, it returns zero.
  1443.      WARNINGS
  1444.       This package usually uses more data space than malloc(3C).
  1445.       The code size    is also    bigger than malloc(3C).
  1446.       Note that unlike malloc(3C), this package does not preserve
  1447.       the contents of a block when it is freed, unless the M_KEEP
  1448.       option of mallopt is used.
  1449.       Undocumented features    of malloc(3C) have not been
  1450.       duplicated.
  1451.  
  1452. #mktemp
  1453. NAME
  1454.       mktemp - make    a unique file name
  1455. SYNTAX
  1456.       char *mktemp (template)
  1457.       char *template;
  1458. DESCRIPTION
  1459.       Mktemp replaces the contents of the string pointed to    by
  1460.       template by a    unique file name, and returns the address of
  1461.       template.  The string    in template should look    like a file
  1462.       name with six    trailing Xs; mktemp will replace the Xs    with a
  1463.       letter and the current process ID.  The letter will be
  1464.       chosen so that the resulting name does not duplicate an
  1465.       existing file.
  1466. SEE ALSO
  1467.       getpid(2), tmpfile(3S), tmpnam(3S).
  1468. BUGS
  1469.       It is    possible to run    out of letters.
  1470.                   
  1471.  
  1472. #perror
  1473. NAME
  1474.       perror, errno, sys_errlist, sys_nerr - system    error messages
  1475. SYNTAX
  1476.       void perror (s)
  1477.       char *s;
  1478.       extern int errno;
  1479.       extern char *sys_errlist[ ];
  1480.       extern int sys_nerr;
  1481. DESCRIPTION
  1482.       Perror produces a message on the standard error output,
  1483.       describing the last error encountered    during a call to a
  1484.       system or library function.  The argument string s is
  1485.       printed first, then a    colon and a blank, then    the message
  1486.       and a    new-line.  To be of most use, the argument string
  1487.       should include the name of the program that incurred the
  1488.       error.  The error number is taken from the external variable
  1489.       errno, which is set when errors occur    but not    cleared    when
  1490.       non-erroneous    calls are made.
  1491.       To simplify variant formatting of messages, the array    of
  1492.       message strings sys_errlist is provided; errno can be    used
  1493.       as an    index in this table to get the message string without
  1494.       the new-line.     Sys_nerr is the largest message number
  1495.       provided for in the table; it    should be checked because new
  1496.       error    codes may be added to the system before    they are added
  1497.       to the table.
  1498. SEE ALSO
  1499.       intro(2).
  1500.                   
  1501.  
  1502. #popen
  1503. NAME
  1504.       popen, pclose    - initiate pipe    to/from    a process
  1505. SYNTAX
  1506.       #include <stdio.h>
  1507.       FILE *popen (command,    type)
  1508.       char *command, *type;
  1509.       int pclose (stream)
  1510.       FILE *stream;
  1511. DESCRIPTION
  1512.       The arguments    to popen are pointers to null-terminated
  1513.       strings containing, respectively, a shell command line and
  1514.       an I/O mode, either r    for reading or w for writing.  Popen
  1515.       creates a pipe between the calling program and the command
  1516.       to be    executed.  The value returned is a stream pointer such
  1517.       that one can write to    the standard input of the command, if
  1518.       the I/O mode is w, by    writing    to the file stream; and    one
  1519.       can read from    the standard output of the command, if the I/O
  1520.       mode is r, by    reading    from the file stream.
  1521.       A stream opened by popen should be closed by pclose, which
  1522.       waits    for the    associated process to terminate    and returns
  1523.       the exit status of the command.
  1524.       Because open files are shared, a type    r command may be used
  1525.       as an    input filter and a type    w as an    output filter.
  1526. SEE ALSO
  1527.       pipe(2), wait(2), fclose(3S),    fopen(3S), system(3S).
  1528. DIAGNOSTICS
  1529.       Popen    returns    a NULL pointer if files    or processes cannot be
  1530.       created, or if the shell cannot be accessed.
  1531.       Pclose returns -1 if stream is not associated    with a
  1532.       ``popened'' command.
  1533. BUGS
  1534.       If the original and ``popened'' processes concurrently read
  1535.       or write a common file, neither should use buffered I/O,
  1536.       because the buffering    gets all mixed up.  Problems with an
  1537.       output filter    may be forestalled by careful buffer flushing,
  1538.       e.g. with fflush; see    fclose(3S).
  1539.                   
  1540.  
  1541. #printf
  1542. NAME
  1543.       printf, fprintf, sprintf - print formatted output
  1544. SYNTAX
  1545.       #include <stdio.h>
  1546.       int printf (format [ , arg ] ...  )
  1547.       char *format;
  1548.       int fprintf (stream, format [    , arg ]    ...  )
  1549.       FILE *stream;
  1550.       char *format;
  1551.       int sprintf (s, format [ , arg ] ...    )
  1552.       char *s, format;
  1553. DESCRIPTION
  1554.       Printf places    output on the standard output stream stdout.
  1555.       Fprintf places output    on the named output stream.  Sprintf
  1556.       places ``output,'' followed by the null character (\0), in
  1557.       consecutive bytes starting at    *s; it is the user's
  1558.       responsibility to ensure that    enough storage is available.
  1559.       Each function    returns    the number of characters transmitted
  1560.       (not including the \0    in the case of sprintf), or a negative
  1561.       value    if an output error was encountered.
  1562.       Each of these    functions converts, formats, and prints    its
  1563.       args under control of    the format.  The format    is a character
  1564.       string that contains two types of objects:  plain
  1565.       characters, which are    simply copied to the output stream,
  1566.       and conversion specifications, each of which results in
  1567.       fetching of zero or more args.  The results are undefined if
  1568.       there    are insufficient args for the format.  If the format
  1569.       is exhausted while args remain, the excess args are simply
  1570.       ignored.
  1571.       Each conversion specification    is introduced by the character
  1572.       %.  After the    %, the following appear    in sequence:
  1573.            Zero or more flags, which modify    the meaning of the
  1574.            conversion specification.
  1575.            An optional decimal digit string    specifying a minimum
  1576.            field width.  If    the converted value has    fewer
  1577.            characters than the field width,    it will    be padded on
  1578.            the left    (or right, if the left-adjustment flag `-',
  1579.            described below,    has been given)    to the field width.
  1580.            If the field width for an s conversion is preceded by a
  1581.            0, the string is    right adjusted with zero-padding on
  1582.            the left.
  1583.            A precision that    gives the minimum number of digits to
  1584.                   
  1585.            appear for the d, o, u, x, or X conversions, the    number
  1586.            of digits to appear after the decimal point for the e
  1587.            and f conversions, the maximum number of    significant
  1588.            digits for the g    conversion, or the maximum number of
  1589.            characters to be    printed    from a string in s conversion.
  1590.            The precision takes the form of a period    (.)  followed
  1591.            by a decimal digit string; a null digit string is
  1592.            treated as zero.
  1593.            An optional l (ell) specifying that a following d, o,
  1594.            u, x, or    X conversion character applies to a long
  1595.            integer arg.  A l before    any other conversion character
  1596.            is ignored.
  1597.            A character that    indicates the type of conversion to be
  1598.            applied.
  1599.       A field width    or precision may be indicated by an asterisk
  1600.       (*) instead of a digit string.  In this case,    an integer arg
  1601.       supplies the field width or precision.  The arg that is
  1602.       actually converted is    not fetched until the conversion
  1603.       letter is seen, so the args specifying field width or
  1604.       precision must appear    before the arg (if any)    to be
  1605.       converted.
  1606.       The flag characters and their    meanings are:
  1607.       -        The    result of the conversion will be left-
  1608.             justified within the field.
  1609.       +        The    result of a signed conversion will always
  1610.             begin with a sign (+ or -).
  1611.       blank        If the first character of a    signed conversion is
  1612.             not    a sign,    a blank    will be    prefixed to the
  1613.             result.  This implies that if the blank and    +
  1614.             flags both appear, the blank flag will be ignored.
  1615.       #        This flag specifies    that the value is to be
  1616.             converted to an ``alternate    form.''     For c,    d, s,
  1617.             and    u conversions, the flag    has no effect.    For o
  1618.             conversion,    it increases the precision to force
  1619.             the    first digit of the result to be    a zero.     For x
  1620.             or X conversion, a non-zero    result will have 0x or
  1621.             0X prefixed    to it.    For e, E, f, g,    and G
  1622.             conversions, the result will always    contain    a
  1623.             decimal point, even    if no digits follow the    point
  1624.             (normally, a decimal point appears in the result
  1625.             of these conversions only if a digit follows it).
  1626.             For    g and G    conversions, trailing zeroes will not
  1627.             be removed from the    result (which they normally
  1628.             are).
  1629.       The conversion characters and    their meanings are:
  1630.       d,o,u,x,x The    integer    arg is converted to signed decimal,
  1631.             unsigned octal, decimal, or    hexadecimal notation
  1632.             (x and X), respectively; the letters abcdef    are
  1633.             used for x conversion and the letters ABCDEF for X
  1634.             conversion.     The precision specifies the minimum
  1635.             number of digits to    appear;    if the value being
  1636.             converted can be represented in fewer digits, it
  1637.             will be expanded with leading zeroes.  (For
  1638.             compatibility with older versions, padding with
  1639.             leading zeroes may alternatively be    specified by
  1640.             prepending a zero to the field width.  This    does
  1641.             not    imply an octal value for the field width.)
  1642.             The    default    precision is 1.     The result of
  1643.             converting a zero value with a precision of    zero
  1644.             is a null string.
  1645.       f        The    float or double    arg is converted to decimal
  1646.             notation in    the style ``[-]ddd.ddd,'' where    the
  1647.             number of digits after the decimal point is    equal
  1648.             to the precision specification.  If    the precision
  1649.             is missing,    six digits are output; if the
  1650.             precision is explicitly 0, no decimal point
  1651.             appears.
  1652.       e,E        The    float or double    arg is converted in the    style
  1653.             ``[-]d.ddde_dd,'' where there is one digit before
  1654.             the    decimal    point and the number of    digits after
  1655.             it is equal    to the precision; when the precision
  1656.             is missing,    six digits are produced; if the
  1657.             precision is zero, no decimal point    appears.  The
  1658.             E format code will produce a number    with E instead
  1659.             of e introducing the exponent.  The    exponent
  1660.             always contains at least two digits.
  1661.       g,G        The    float or double    arg is printed in style    f or e
  1662.             (or    in style E in the case of a G format code),
  1663.             with the precision specifying the number of
  1664.             significant    digits.     The style used    depends    on the
  1665.             value converted:  style e will be used only    if the
  1666.             exponent resulting from the    conversion is less
  1667.             than -4 or greater than the    precision.  Trailing
  1668.             zeroes are removed from the    result;    a decimal
  1669.             point appears only if it is    followed by a digit.
  1670.       c        The    character arg is printed.
  1671.       s        The    arg is taken to    be a string (character
  1672.             pointer) and characters from the string are
  1673.             printed until a null character (\0)    is encountered
  1674.             or the number of characters    indicated by the
  1675.             precision specification is reached.     If the
  1676.             precision is missing, it is    taken to be infinite,
  1677.             so all characters up to the    first null character
  1678.             are    printed.  A NULL value for arg will yield
  1679.             undefined results.
  1680.       %        Print a %; no argument is converted.
  1681.       In no    case does a non-existent or small field    width cause
  1682.       truncation of    a field; if the    result of a conversion is
  1683.       wider    than the field width, the field    is simply expanded to
  1684.       contain the conversion result.  Characters generated by
  1685.       printf and fprintf are printed as if putc(3S)    had been
  1686.       called.
  1687.      EXAMPLES
  1688.       To print a date and time in the form ``Sunday, July 3,
  1689.       10:02,'' where weekday and month are pointers    to null-
  1690.       terminated strings:
  1691.            printf("%s, %s %d, %d:%.2d", weekday, month, day, hour, min);
  1692.       To print pi to 5 decimal places:
  1693.            printf("pi = %.5f", 4 * atan(1.0));
  1694. SEE ALSO
  1695.       ecvt(3C), putc(3S), scanf(3S), stdio(3S).
  1696.  
  1697. #putc
  1698. NAME
  1699.       putc,    putchar, fputc,    putw - put character or    word on    a
  1700.       stream
  1701. SYNTAX
  1702.       #include <stdio.h>
  1703.       int putc (c, stream)
  1704.       int c;
  1705.       FILE *stream;
  1706.       int putchar (c)
  1707.       int c;
  1708.       int fputc (c,    stream)
  1709.       int c;
  1710.       FILE *stream;
  1711.       int putw (w, stream)
  1712.       int w;
  1713.       FILE *stream;
  1714. DESCRIPTION
  1715.       Putc writes the character c onto the output stream (at the
  1716.       position where the file pointer, if defined, is pointing).
  1717.       Putchar(c) is    defined    as putc(c, stdout).  Putc and putchar
  1718.       are macros.
  1719.       Fputc    behaves    like putc, but is a function rather than a
  1720.       macro.  Fputc    runs more slowly than putc, but    it takes less
  1721.       space    per invocation and its name can    be passed as an
  1722.       argument to a    function.
  1723.       Putw writes the word (i.e., integer) w to the    output stream
  1724.       (at the position at which the    file pointer, if defined, is
  1725.       pointing).  The size of a word is the    size of    an integer and
  1726.       varies from machine to machine.  Putw    neither    assumes    nor
  1727.       causes special alignment in the file.
  1728.       Output streams, with the exception of    the standard error
  1729.       stream stderr, are by    default    buffered if the    output refers
  1730.       to a file and    line-buffered if the output refers to a
  1731.       terminal.  The standard error    output stream stderr is    by
  1732.       default unbuffered, but use of freopen [see fopen(3S)] will
  1733.       cause    it to become buffered or line-buffered.     When an
  1734.       output stream    is unbuffered, information is queued for
  1735.       writing on the destination file or terminal as soon as
  1736.       written; when    it is buffered,    many characters    are saved up
  1737.       and written as a block.  When    it is line-buffered, each line
  1738.       of output is queued for writing on the destination terminal
  1739.       as soon as the line is completed (that is, as    soon as    a
  1740.       new-line character is    written    or terminal input is
  1741.                   
  1742.       requested).  Setbuf(3S) or Setbuf(3S)    may be used to change
  1743.       the stream's buffering strategy.
  1744. SEE ALSO
  1745.       fclose(3S), ferror(3S), fopen(3S), fread(3S),    printf(3S),
  1746.       puts(3S), setbuf(3S).
  1747. DIAGNOSTICS
  1748.       On success, putc, fputc, and putchar each return the value
  1749.       they have written.  On failure, they return the constant
  1750.       EOF.    This will occur    if the file stream is not open for
  1751.       writing or if    the output file    cannot be grown.  Putw returns
  1752.       nonzero when an error    has occured, otherwise zero.
  1753. BUGS
  1754.       Because it is    implemented as a macro,    putc treats
  1755.       incorrectly a    stream argument    with side effects.  In
  1756.       particular, putc(c, *f++); doesn't work sensibly.  Fputc
  1757.       should be used instead.
  1758.       Because of possible differences in word length and byte
  1759.       ordering, files written using    putw are machine-dependent,
  1760.       and may not be read using getw on a different    processor.
  1761.  
  1762. #putenv
  1763. NAME
  1764.       putenv - change or add value to environment
  1765. SYNTAX
  1766.       int putenv (string)
  1767.       char *string;
  1768. DESCRIPTION
  1769.       String points    to a string of the form    ``name=value.''
  1770.       Putenv makes the value of the    environment variable name
  1771.       equal    to value by altering an    existing variable or creating
  1772.       a new    one.  In either    case, the string pointed to by string
  1773.       becomes part of the environment, so altering the string will
  1774.       change the environment.  The space used by string is no
  1775.       longer used once a new string-defining name is passed    to
  1776.       putenv.
  1777. DIAGNOSTICS
  1778.       Putenv returns non-zero if it    was unable to obtain enough
  1779.       space    via malloc for an expanded environment,    otherwise
  1780.       zero.
  1781. SEE ALSO
  1782.       exec(2), getenv(3C), malloc(3C), environ(5).
  1783.      WARNINGS
  1784.       Putenv manipulates the environment pointed to    by environ,
  1785.       and can be used in conjunction with getenv.  However,    envp
  1786.       (the third argument to main) is not changed.
  1787.       This routine uses malloc(3C) to enlarge the environment.
  1788.       After    putenv is called, environmental    variables are not in
  1789.       alphabetical order.
  1790.       A potential error is to call putenv with an automatic
  1791.       variable as the argument, then exit the calling function
  1792.       while    string is still    part of    the environment.
  1793.                   
  1794.  
  1795. #puts
  1796. NAME
  1797.       puts,    fputs -    put a string on    a stream
  1798. SYNTAX
  1799.       #include <stdio.h>
  1800.       int puts (s)
  1801.       char *s;
  1802.       int fputs (s,    stream)
  1803.       char *s;
  1804.       FILE *stream;
  1805. DESCRIPTION
  1806.       Puts writes the null-terminated string pointed to by s,
  1807.       followed by a    new-line character, to the standard output
  1808.       stream stdout.
  1809.       Fputs    writes the null-terminated string pointed to by    s to
  1810.       the named output stream.
  1811.       Neither function writes the terminating null character.
  1812. DIAGNOSTICS
  1813.       Both routines    return EOF on error. This will happen if the
  1814.       routines try to write    on a file that has not been opened for
  1815.       writing.
  1816. SEE ALSO
  1817.       ferror(3S), fopen(3S), fread(3S), printf(3S),    putc(3S).
  1818.      NOTES
  1819.       Puts appends a new-line character while fputs    does not.
  1820.                   
  1821.  
  1822. #qsort
  1823. NAME
  1824.       qsort    - quicker sort
  1825. SYNTAX
  1826.       void qsort ((char *) base, nel, sizeof (*base), compar)
  1827.       unsigned nel;
  1828.       int (*compar)( );
  1829. DESCRIPTION
  1830.       Qsort    is an implementation of    the quicker-sort algorithm.
  1831.       It sorts a table of data in place.
  1832.       Base points to the element at    the base of the    table.    Nel is
  1833.       the number of    elements in the    table.    Compar is the name of
  1834.       the comparison function, which is called with    two arguments
  1835.       that point to    the elements being compared.  As the function
  1836.       must return an integer less than, equal to, or greater than
  1837.       zero,    so must    the first argument to be considered be less
  1838.       than,    equal to, or greater than the second.
  1839.      NOTES
  1840.       The pointer to the base of the table should be of type
  1841.       pointer-to-element, and cast to type pointer-to-character.
  1842.       The comparison function need not compare every byte, so
  1843.       arbitrary data may be    contained in the elements in addition
  1844.       to the values    being compared.
  1845.       The order in the output of two items which compare as    equal
  1846.       is unpredictable.
  1847. SEE ALSO
  1848.       bsearch(3C), lsearch(3C), string(3C).
  1849.       sort(1) in the UNIX System V User Reference Manual.
  1850.      WARNING
  1851.       The total size of the    table (nel x sizeof(*base)) must be
  1852.       less than 65536 in small and large model programs.
  1853.                   
  1854.  
  1855. #rand
  1856. SUBROUTINES
  1857.     rand(3)        - standard random number generator
  1858. INVOCATION
  1859.     srand( seed )
  1860.       unsigned seed;
  1861.     int rand()
  1862. EXPLANATION
  1863.     Rand(3) uses a full period, mixed linear congruential
  1864.     generator to return a pseudo-random number in the
  1865.     range 0 to 32767 {INT_MAX}. The formula used is:
  1866.       seed = (1103515245 * seed + 12345) % 2147483648
  1867.     Srand(3) sets the seed to an initial value, the default
  1868.     is 1.
  1869. RESULTS
  1870.     Rand(3) returns 15 bits from the high order word of seed.
  1871. REFERENCES
  1872.     lrand(3)
  1873.  
  1874. #regcmp
  1875. NAME
  1876.       regcmp, regex    - compile and execute regular expression
  1877. SYNTAX
  1878.       char *regcmp (string1    [, string2, ...], (char    *)0)
  1879.       char *string1, *string2, ...;
  1880.       char *regex (re, subject[, ret0, ...])
  1881.       char *re, *subject, *ret0, ...;
  1882.       extern char *__loc1;
  1883. DESCRIPTION
  1884.       Regcmp compiles a regular expression and returns a pointer
  1885.       to the compiled form.     Malloc(3C) is used to create space
  1886.       for the vector.  It is the user's responsibility to free
  1887.       unneeded space so allocated.    A NULL return from regcmp
  1888.       indicates an incorrect argument.  Regcmp(1) has been written
  1889.       to generally preclude    the need for this routine at execution
  1890.       time.
  1891.       Regex    executes a compiled pattern against the    subject
  1892.       string.  Additional arguments    are passed to receive values
  1893.       back.     Regex returns NULL on failure or a pointer to the
  1894.       next unmatched character on success.    A global character
  1895.       pointer __loc1 points    to where the match began.  Regcmp and
  1896.       regex    were mostly borrowed from the editor, ed(1); however,
  1897.       the syntax and semantics have    been changed slightly.    The
  1898.       following are    the valid symbols and their associated
  1899.       meanings.
  1900.       []*.^        These symbols retain their current meaning.
  1901.       $        Matches the    end of the string; \n matches a    new-
  1902.             line.
  1903.       -        Within brackets the    minus means through.  For
  1904.             example, [a-z] is equivalent to [abcd...xyz].  The
  1905.             - can appear as itself only    if used    as the first
  1906.             or last character.    For example, the character
  1907.             class expression []-] matches the characters
  1908.             ] and -.
  1909.       +        A regular expression followed by + means one or
  1910.             more times.     For example, [0-9]+ is    equivalent to
  1911.             [0-9][0-9]*.
  1912.       {m} {m,} {m,u}
  1913.             Integer values enclosed in {} indicate the number
  1914.             of times the preceding regular expression is to be
  1915.             applied.  The value    m is the minimum number    and u
  1916.             is a number, less than 256,    which is the maximum.
  1917.                   
  1918.             If only m is present (e.g.,    {m}), it indicates the
  1919.             exact number of times the regular expression is to
  1920.             be applied.     The value {m,}    is analogous to
  1921.             {m,infinity}.  The plus (+)    and star (*)
  1922.             operations are equivalent to {1,} and {0,}
  1923.             respectively.
  1924.       ( ...    )$n The    value of the enclosed regular expression is to
  1925.             be returned.  The value will be stored in the
  1926.             (n+1)th argument following the subject argument.
  1927.             At most ten    enclosed regular expressions are
  1928.             allowed.  Regex makes its assignments
  1929.             unconditionally.
  1930.       ( ...    )   Parentheses    are used for grouping.    An operator,
  1931.             e.g., *, +,    {}, can    work on    a single character or
  1932.             a regular expression enclosed in parentheses.  For
  1933.             example, (a*(cb+)*)$0.
  1934.       By necessity,    all the    above defined symbols are special.
  1935.       They must, therefore,    be escaped to be used as themselves.
  1936.      EXAMPLES
  1937.       Example 1:
  1938.            char *cursor, *newcursor, *ptr;
  1939.             ...
  1940.            newcursor = regex((ptr =    regcmp("^\n", 0)), cursor);
  1941.            free(ptr);
  1942.       This example will match a leading new-line in    the subject
  1943.       string pointed at by cursor.
  1944.       Example 2:
  1945.            char ret0[9];
  1946.            char *newcursor,    *name;
  1947.             ...
  1948.            name = regcmp("([A-Za-z][A-za-z0-9_]{0,7})$0", '(char *)0');
  1949.            newcursor = regex(name, "123Testing321",    ret0);
  1950.       This example will match through the string ``Testing3'' and
  1951.       will return the address of the character after the last
  1952.       matched character (cursor+11).  The string ``Testing3'' will
  1953.       be copied to the character array ret0.
  1954.       Example 3:
  1955.            #include    "file.i"
  1956.            char *string, *newcursor;
  1957.             ...
  1958.            newcursor = regex(name, string);
  1959.       This example applies a precompiled regular expression    in
  1960.       file.i [see regcmp(1)] against string.
  1961.       This routine is kept in /lib/<module>/libPW.a, where module
  1962.       is either small or large.
  1963. SEE ALSO
  1964.       malloc(3C).
  1965.       ed(1), regcmp(1) in the UNIX System V    User Reference Manual.
  1966. BUGS
  1967.       The user program may run out of memory if regcmp is called
  1968.       iteratively without freeing the vectors no longer required.
  1969.       The following    user-supplied replacement for malloc(3C)
  1970.       reuses the same vector, saving time and space:
  1971.            /* user's program */
  1972.             ...
  1973.            char *
  1974.            malloc(n)
  1975.            unsigned    n;
  1976.            {
  1977.             static char    rebuf[512];
  1978.             return (n <= sizeof    rebuf) ? rebuf : NULL;
  1979.            }
  1980.  
  1981. #rename
  1982. .TH RENAME 3 "Standard Extension"
  1983. .SH NAME
  1984. rename \- change the name of a file
  1985. .SH SYNOPSIS
  1986. .ft B
  1987. .nf
  1988. rename(from, to)
  1989. char *from, *to;
  1990. .fi
  1991. .ft R
  1992. .SH DESCRIPTION
  1993. .I Rename
  1994. causes the link named
  1995. .I from
  1996. to be renamed as
  1997. .IR to .
  1998. If 
  1999. .I to
  2000. exists, then it is first removed.
  2001. Both 
  2002. .I from
  2003. and
  2004. .I to
  2005. must be of the same type (i.e., both directories or both
  2006. non-directories), and must reside on the same file system.
  2007. .PP
  2008. .I Rename
  2009. guarantees that an instance of
  2010. .I to
  2011. will always exist, even if the system should crash in
  2012. the middle of the operation.
  2013. .SH CAVEAT
  2014. The system can deadlock if a loop in the file system graph is present.
  2015. This loop takes the form of an entry in directory \*(lqa\*(rq,
  2016. say \*(lqa/foo\*(rq,
  2017. being a hard link to directory \*(lqb\*(rq, and an entry in
  2018. directory \*(lqb\*(rq, say \*(lqb/bar\*(rq, being a hard link
  2019. to directory \*(lqa\*(rq.
  2020. When such a loop exists and two separate processes attempt to
  2021. perform \*(lqrename a/foo b/bar\*(rq and \*(lqrename b/bar a/foo\*(rq,
  2022. respectively, 
  2023. the system may deadlock attempting to lock
  2024. both directories for modification.
  2025. On systems with a symbolic link capability, hard links to directories should be
  2026. replaced by symbolic links by the system administrator.
  2027. .SH "RETURN VALUE"
  2028. A 0 value is returned if the operation succeeds, otherwise
  2029. .I rename
  2030. returns \-1 and the global variable
  2031. .I errno
  2032. indicates the reason for the failure.
  2033. .SH "ERRORS
  2034. .I Rename
  2035. will fail and nothing will change if any of the following are true:
  2036. .TP 15
  2037. [ENOTDIR]
  2038. A component of either path prefix is not a directory.
  2039. .TP 15
  2040. [ENOENT]
  2041. A component of either path prefix does not exist.
  2042. .TP 15
  2043. [EACCES]
  2044. A component of either path prefix denies search permission.
  2045. .TP 15
  2046. [ENOENT]
  2047. The file named by \fIfrom\fP does not exist.
  2048. .TP 15
  2049. [EXDEV]
  2050. The link named by \fIto\fP and the file named by \fIfrom\fP
  2051. are on different logical devices (file systems).  Note that this error
  2052. code will not be returned if the implementation permits cross-device
  2053. links.
  2054. .TP 15
  2055. [EACCES]
  2056. The requested link requires writing in a directory with a mode
  2057. that denies write permission.
  2058. .TP 15
  2059. [EROFS]
  2060. The requested link requires writing in a directory on a read-only file
  2061. system.
  2062. .TP 15
  2063. [EFAULT]
  2064. .I Path
  2065. points outside the process's allocated address space.
  2066. .SH "SEE ALSO"
  2067. open(2)
  2068.  
  2069. #scanf
  2070. NAME
  2071.       scanf, fscanf, sscanf    - convert formatted input
  2072. SYNTAX
  2073.       #include <stdio.h>
  2074.       int scanf (format [ ,    pointer    ] ...  )
  2075.       char *format;
  2076.       int fscanf (stream, format [ , pointer ] ...    )
  2077.       FILE *stream;
  2078.       char *format;
  2079.       int sscanf (s, format    [ , pointer ] ...  )
  2080.       char *s, *format;
  2081. DESCRIPTION
  2082.       Scanf    reads from the standard    input stream stdin.  Fscanf
  2083.       reads    from the named input stream.  Sscanf reads from    the
  2084.       character string s.  Each function reads characters,
  2085.       interprets them according to a format, and stores the
  2086.       results in its arguments.  Each expects, as arguments, a
  2087.       control string format    described below, and a set of pointer
  2088.       arguments indicating where the converted input should    be
  2089.       stored.
  2090.       The control string usually contains conversion
  2091.       specifications, which    are used to direct interpretation of
  2092.       input    sequences.  The    control    string may contain:
  2093.       1. White-space characters (blanks, tabs, new-lines, or
  2094.          form-feeds) which,    except in two cases described below,
  2095.          cause input to be read up to the next non-white-space
  2096.          character.
  2097.       2. An    ordinary character (not    %), which must match the next
  2098.          character of the input stream.
  2099.       3. Conversion    specifications,    consisting of the character %,
  2100.          an    optional assignment suppressing    character *, an
  2101.          optional numerical    maximum    field width, an    optional l
  2102.          (ell) or h    indicating the size of the receiving variable,
  2103.          and a conversion code.
  2104.       A conversion specification directs the conversion of the
  2105.       next input field; the    result is placed in the    variable
  2106.       pointed to by    the corresponding argument, unless assignment
  2107.       suppression was indicated by *.  The suppression of
  2108.       assignment provides a    way of describing an input field which
  2109.       is to    be skipped.  An    input field is defined as a string of
  2110.       non-space characters;    it extends to the next inappropriate
  2111.       character or until the field width, if specified, is
  2112.       exhausted.  For all descriptors except ``['' and ``c'',
  2113.       white    space leading an input field is    ignored.
  2114.                   
  2115.       The conversion code indicates    the interpretation of the
  2116.       input    field; the corresponding pointer argument must usually
  2117.       be of    a restricted type.  For    a suppressed field, no pointer
  2118.       argument is given.  The following conversion codes are
  2119.       legal:
  2120.       %    a single    % is expected in the input at this point; no
  2121.            assignment is done.
  2122.       d    a decimal integer is expected; the corresponding
  2123.            argument    should be an integer pointer.
  2124.       u    an unsigned decimal integer is expected;    the
  2125.            corresponding argument should be    an unsigned integer
  2126.            pointer.
  2127.       o    an octal    integer    is expected; the corresponding
  2128.            argument    should be an integer pointer.
  2129.       x    a hexadecimal integer is    expected; the corresponding
  2130.            argument    should be an integer pointer.
  2131.       e,f,g
  2132.            a floating point    number is expected; the    next field is
  2133.            converted accordingly and stored    through    the
  2134.            corresponding argument, which should be a pointer to a
  2135.            float.  The input format    for floating point numbers is
  2136.            an optionally signed string of digits, possibly
  2137.            containing a decimal point, followed by an optional
  2138.            exponent    field consisting of an E or an e, followed by
  2139.            an optional +, -, or space, followed by an integer.
  2140.       s    a character string is expected; the corresponding
  2141.            argument    should be a character pointer pointing to an
  2142.            array of    characters large enough    to accept the string
  2143.            and a terminating \0, which will    be added
  2144.            automatically.  The input field is terminated by    a
  2145.            white-space character.
  2146.       c    a character is expected;    the corresponding argument
  2147.            should be a character pointer.  The normal skip over
  2148.            white space is suppressed in this case; to read the
  2149.            next non-space character, use %1s.  If a    field width is
  2150.            given, the corresponding    argument should    refer to a
  2151.            character array;    the indicated number of    characters is
  2152.            read.
  2153.       [    indicates string    data and the normal skip over leading
  2154.            white space is suppressed.  The left bracket is
  2155.            followed    by a set of characters,    which we will call the
  2156.            scanset,    and a right bracket; the input field is    the
  2157.            maximal sequence    of input characters consisting
  2158.            entirely    of characters in the scanset.  The circumflex
  2159.            (^), when it appears as the first character in the
  2160.            scanset,    serves as a complement operator    and redefines
  2161.            the scanset as the set of all characters    not contained
  2162.            in the remainder    of the scanset string.    There are some
  2163.            conventions used    in the construction of the scanset.  A
  2164.            range of    characters may be represented by the construct
  2165.            first-last, thus    [0123456789] may be expressed [0-9].
  2166.            Using this convention, first must be lexically less
  2167.            than or equal to    last, or else the dash will stand for
  2168.            itself.    The dash will also stand for itself whenever
  2169.            it is the first or the last character in    the scanset.
  2170.            To include the right square bracket as an element of
  2171.            the scanset, it must appear as the first    character
  2172.            (possibly preceded by a circumflex) of the scanset, and
  2173.            in this case it will not    be syntactically interpreted
  2174.            as the closing bracket.    The corresponding argument
  2175.            must point to a character array large enough to hold
  2176.            the data    field and the terminating \0, which will be
  2177.            added automatically.  At    least one character must match
  2178.            for this    conversion to be considered successful.
  2179.       The conversion characters d, u, o, and x may be preceded by
  2180.       l or h to indicate that a pointer to long or to short    rather
  2181.       than to int is in the    argument list.    Similarly, the
  2182.       conversion characters    e, f, and g may    be preceded by l to
  2183.       indicate that    a pointer to double rather than    to float is in
  2184.       the argument list.  The l or h modifier is ignored for other
  2185.       conversion characters.
  2186.       Scanf    conversion terminates at EOF, at the end of the
  2187.       control string, or when an input character conflicts with
  2188.       the control string.  In the latter case, the offending
  2189.       character is left unread in the input    stream.
  2190.       Scanf    returns    the number of successfully matched and
  2191.       assigned input items;    this number can    be zero    in the event
  2192.       of an    early conflict between an input    character and the
  2193.       control string.  If the input    ends before the    first conflict
  2194.       or conversion, EOF is    returned.
  2195.      EXAMPLES
  2196.       The call:
  2197.            int i, n; float x; char name[50];
  2198.            n = scanf("%d%f%s", &i, &x, name);
  2199.       with the input line:
  2200.            25 54.32E-1 thompson
  2201.       will assign to n the value 3,    to i the value 25, to x    the
  2202.       value    5.432, and name    will contain thompson\0.  Or:
  2203.            int i; float x; char name[50];
  2204.            (void) scanf("%2d%f%*d %[0-9]", &i, &x, name);
  2205.       with input:
  2206.            56789 0123 56a72
  2207.       will assign 56 to i, 789.0 to    x, skip    0123, and place    the
  2208.       string 56\0 in name.    The next call to getchar (see
  2209.       getc(3S)) will return    a.
  2210. SEE ALSO
  2211.       getc(3S), printf(3S),    strtod(3C), strtol(3C).
  2212.      NOTE
  2213.       Trailing white space (including a new-line) is left unread
  2214.       unless matched in the    control    string.
  2215. DIAGNOSTICS
  2216.       These    functions return EOF on    end of input and a short count
  2217.       for missing or illegal data items.
  2218. BUGS
  2219.       The success of literal matches and suppressed    assignments is
  2220.       not directly determinable.
  2221.  
  2222. #setbuf
  2223. NAME
  2224.       setbuf, setvbuf - assign buffering to    a stream
  2225. SYNTAX
  2226.       #include <stdio.h>
  2227.       void setbuf (stream, buf)
  2228.       FILE *stream;
  2229.       char *buf;
  2230.       int setvbuf (stream, buf, type, size)
  2231.       FILE *stream;
  2232.       char *buf;
  2233.       int type, size;
  2234. DESCRIPTION
  2235.       Setbuf may be    used after a stream has    been opened but    before
  2236.       it is    read or    written.  It causes the    array pointed to by
  2237.       buf to be used instead of an automatically allocated buffer.
  2238.       If buf is the    NULL pointer input/output will be completely
  2239.       unbuffered.
  2240.       A constant BUFSIZ, defined in    the <stdio.h> header file,
  2241.       tells    how big    an array is needed:
  2242.            char buf[BUFSIZ];
  2243.       Setvbuf may be used after a stream has been opened but
  2244.       before it is read or written.     Type determines how stream
  2245.       will be buffered.  Legal values for type (defined in
  2246.       stdio.h) are:
  2247.       _IOFBF  causes input/output to be fully buffered.
  2248.       _IOLBF  causes output    to be line buffered; the buffer    will
  2249.           be flushed when a newline is written,    the buffer is
  2250.           full,    or input is requested.
  2251.       _IONBF  causes input/output to be completely unbuffered.
  2252.       If buf is not    the NULL pointer, the array it points to will
  2253.       be used for buffering, instead of an automatically allocated
  2254.       buffer.  Size    specifies the size of the buffer to be used.
  2255.       The constant BUFSIZ in <stdio.h> is suggested    as a good
  2256.       buffer size.    If input/output    is unbuffered, buf and size
  2257.       are ignored.
  2258.       By default, output to    a terminal is line buffered and    all
  2259.       other    input/output is    fully buffered.
  2260. SEE ALSO
  2261.       fopen(3S), getc(3S), malloc(3C), putc(3S), stdio(3S).
  2262.                   
  2263. DIAGNOSTICS
  2264.       If an    illegal    value for type or size is provided, setvbuf
  2265.       returns a non-zero value. Otherwise, the value returned will
  2266.       be zero.
  2267.      NOTE
  2268.       A common source of error is allocating buffer    space as an
  2269.       ``automatic''    variable in a code block, and then failing to
  2270.       close    the stream in the same block.
  2271.  
  2272. #setjmp
  2273. NAME
  2274.       setjmp, longjmp - non-local goto
  2275. SYNTAX
  2276.       #include <setjmp.h>
  2277.       int setjmp (env)
  2278.       jmp_buf env;
  2279.       void longjmp (env, val)
  2280.       jmp_buf env;
  2281.       int val;
  2282. DESCRIPTION
  2283.       These    functions are useful for dealing with errors and
  2284.       interrupts encountered in a low-level    subroutine of a
  2285.       program.
  2286.       Setjmp saves its stack environment in    env (whose type,
  2287.       jmp_buf, is defined in the <setjmp.h>    header file) for later
  2288.       use by longjmp.  It returns the value    0.
  2289.       Longjmp restores the environment saved by the    last call of
  2290.       setjmp with the corresponding    env argument.  After longjmp
  2291.       is completed,    program    execution continues as if the
  2292.       corresponding    call of    setjmp (which must not itself have
  2293.       returned in the interim) had just returned the value val.
  2294.       Longjmp cannot cause setjmp to return    the value 0.  If
  2295.       longjmp is invoked with a second argument of 0, setjmp will
  2296.       return 1.  All accessible data had values as of the time
  2297.       longjmp was called.
  2298. SEE ALSO
  2299.       signal(2).
  2300.      WARNING
  2301.       If longjmp is    called even though env was never primed    by a
  2302.       call to setjmp, or when the last such    call was in a function
  2303.       which    has since returned, absolute chaos is guaranteed.
  2304.                   
  2305.  
  2306. #signal
  2307. NAME
  2308.       signal - specify FORTRAN action on receipt of    a system
  2309.       signal
  2310. SYNTAX
  2311.       integer i
  2312.       external integer intfnc
  2313.       call signal(i, intfnc)
  2314. DESCRIPTION
  2315.       Signal allows    a process to specify a function    to be invoked
  2316.       upon receipt of a specific signal. The first argument
  2317.       specifies which fault    or exception; the second argument the
  2318.       specific function to be invoked.
  2319. SEE ALSO
  2320.       kill(2), signal(2).
  2321.                   
  2322.  
  2323. #sleep
  2324. NAME
  2325.       sleep    - suspend execution for    interval
  2326. SYNTAX
  2327.       unsigned sleep (seconds)
  2328.       unsigned seconds;
  2329. DESCRIPTION
  2330.       The current process is suspended from    execution for the
  2331.       number of seconds specified by the argument.    The actual
  2332.       suspension time may be less than that    requested for two
  2333.       reasons: (1) Because scheduled wakeups occur at fixed    1-
  2334.       second intervals, (on    the second, according to an internal
  2335.       clock) and (2) because any caught signal will    terminate the
  2336.       sleep    following execution of that signal's catching routine.
  2337.       Also,    the suspension time may    be longer than requested by an
  2338.       arbitrary amount due to the scheduling of other activity in
  2339.       the system.  The value returned by sleep will    be the
  2340.       ``unslept'' amount (the requested time minus the time
  2341.       actually slept) in case the caller had an alarm set to go
  2342.       off earlier than the end of the requested sleep time,    or
  2343.       premature arousal due    to another caught signal.
  2344.       The routine is implemented by    setting    an alarm signal    and
  2345.       pausing until    it (or some other signal) occurs.  The
  2346.       previous state of the    alarm signal is    saved and restored.
  2347.       The calling program may have set up an alarm signal before
  2348.       calling sleep.  If the sleep time exceeds the    time till such
  2349.       alarm    signal,    the process sleeps only    until the alarm    signal
  2350.       would    have occurred.    The caller's alarm catch routine is
  2351.       executed just    before the sleep routine returns.  But if the
  2352.       sleep    time is    less than the time till    such alarm, the    prior
  2353.       alarm    time is    reset to go off    at the same time it would have
  2354.       without the intervening sleep.
  2355. SEE ALSO
  2356.       alarm(2), pause(2), signal(2).
  2357.                   
  2358.  
  2359. #stdio
  2360. NAME
  2361.       stdio    - standard buffered input/output package
  2362. SYNTAX
  2363.       #include <stdio.h>
  2364.       FILE *stdin, *stdout,    *stderr;
  2365. DESCRIPTION
  2366.       The functions    described in the entries of sub-class 3S of
  2367.       this manual constitute an efficient, user-level I/O
  2368.       buffering scheme.  The in-line macros    getc(3S) and putc(3S)
  2369.       handle characters quickly.  The macros getchar and putchar,
  2370.       and the higher-level routines    fgetc, fgets, fprintf, fputc,
  2371.       fputs, fread,    fscanf,    fwrite,    gets, getw, printf, puts,
  2372.       putw,    and scanf all use or act as if they use    getc and putc;
  2373.       they can be freely intermixed.
  2374.       A file with associated buffering is called a stream and is
  2375.       declared to be a pointer to a    defined    type FILE.  Fopen(3S)
  2376.       creates certain descriptive data for a stream    and returns a
  2377.       pointer to designate the stream in all further transactions.
  2378.       Normally, there are three open streams with constant
  2379.       pointers declared in the <stdio.h> header file and
  2380.       associated with the standard open files:
  2381.            stdin     standard input    file
  2382.            stdout     standard output file
  2383.            stderr     standard error    file
  2384.       A constant NULL (0) designates a nonexistent pointer.
  2385.       An integer-constant EOF (-1) is returned upon    end-of-file or
  2386.       error    by most    integer    functions that deal with streams (see
  2387.       the individual descriptions for details).
  2388.       An integer constant BUFSIZ specifies the size    of the buffers
  2389.       used by the particular implementation.
  2390.       Any program that uses    this package must include the header
  2391.       file of pertinent macro definitions, as follows:
  2392.            #include    <stdio.h>
  2393.       The functions    and constants mentioned    in the entries of
  2394.       sub-class 3S of this manual are declared in that header file
  2395.       and need no further declaration.  The    constants and the
  2396.       following ``functions'' are implemented as macros
  2397.       (redeclaration of these names    is perilous):  getc, getchar,
  2398.       putc,    putchar, ferror, feof, clearerr, and fileno.
  2399. SEE ALSO
  2400.                   
  2401.       open(2), close(2), lseek(2), pipe(2),    read(2), write(2),
  2402.       ctermid(3S), cuserid(3S), fclose(3S),    ferror(3S), fopen(3S),
  2403.       fread(3S), fseek(3S),    getc(3S), gets(3S), popen(3S),
  2404.       printf(3S), putc(3S),    puts(3S), scanf(3S), setbuf(3S),
  2405.       system(3S), tmpfile(3S), tmpnam(3S), ungetc(3S).
  2406. DIAGNOSTICS
  2407.       Invalid stream pointers will usually cause grave disorder,
  2408.       possibly including program termination.  Individual function
  2409.       descriptions describe    the possible error conditions.
  2410.  
  2411. #strcmp
  2412. NAME
  2413.       lge, lgt, lle, llt - string comparison intrinsic functions
  2414. SYNTAX
  2415.       character*N     a1, a2
  2416.       logical   l
  2417.       l = lge (a1,a2)
  2418.       l = lgt (a1,a2)
  2419.       l = lle (a1,a2)
  2420.       l = llt (a1,a2)
  2421. DESCRIPTION
  2422.       These    functions return .TRUE.    if the inequality holds    and
  2423.       .FALSE. otherwise.
  2424.                   
  2425.  
  2426. #toascii
  2427. NAME
  2428.     toascii - convert to ASCII
  2429.  
  2430. SYNTAX
  2431.     #include <ctype.h>
  2432.  
  2433.     int toascii( c )
  2434.       int c;
  2435.  
  2436. DESCRIPTION
  2437.     Toascii(3) maps an int into a value from 0 to 127.
  2438.     This is necessary for some functions, such as
  2439.     isupper(3).
  2440.  
  2441. RESULTS
  2442.     Lower seven bits of <c>.
  2443.  
  2444. SEE ALSO
  2445.     ctype(3), tolower(3), toupper(3)
  2446.  
  2447. #tolower
  2448. NAME
  2449.     tolower(3)        - convert to lower case
  2450.  
  2451. SYNTAX
  2452.     #include <ctype.h>
  2453.  
  2454.     int tolower( c )
  2455.       int c;
  2456.  
  2457.     int _tolower( c )
  2458.       int c;
  2459.  
  2460. DESCRIPTION
  2461.     These routines convert upper case ASCII characters
  2462.     into lower case characters. Tolower(3) may be called
  2463.     with any ASCII value from 0 to 127, if <c> is not an
  2464.     upper case character then it is returned unchanged.
  2465.  
  2466.     _tolower(3) is a macro which can only be used if <c>
  2467.     is an upper case character.
  2468.  
  2469. RESULTS
  2470.     Argument converted to lower case.
  2471.  
  2472. SEE ALSO
  2473.     ctype(3), toascii(3), toupper(3)
  2474.  
  2475. #toupper
  2476. NAME
  2477.     toupper(3)        - convert to upper case
  2478.  
  2479. SYNTAX
  2480.     #include <ctype.h>
  2481.  
  2482.     int toupper( c )
  2483.       int c;
  2484.  
  2485.     int _toupper( c )
  2486.       int c;
  2487.  
  2488. DESCRIPTION
  2489.     These routines convert lower case ASCII characters
  2490.     into upper case characters. Toupper(3) may be called
  2491.     with any ASCII value from 0 to 127, if <c> is not a
  2492.     lower case character then it is returned unchanged.
  2493.  
  2494.     _toupper(3) is a macro which can only be used if <c>
  2495.     is a lower case character.
  2496.  
  2497. RESULTS
  2498.     Argument converted to upper case.
  2499.  
  2500. SEE ALSO
  2501.     ctype(3), toascii(3), tolower(3)
  2502.